[RUBY] Use WHERE to retrieve the result calculated using the Mysql syntax

Introduction

This is my first post. In his 20s, he is a fledgling engineer who has real estate, has no experience in his 30s, and has been offered a job hunting by the company he developed in-house. Today I will write about Mysql.

It is a program that extracts items that meet certain conditions from land data. We will pick up land with a unit price of 1 million yen or less.

From create TABLE.


--Create table(Column: id:m2 :price)
CREATE TABLE rands(
 id INT NOT NULL AUTO_INCREMENT,
 m2 INT,
 price INT,
 PRIMARY KEY (id)
);

--Then put the data in the table
INSERT INTO rands (m2, price) VALUES
 (200, 100000000),
 (300, 30000000),
 (500, 40000000),
 (100, 50000000);

--* SELECT (all data) and retrieve the data from the rands table in a form that meets the conditions with WHERE.
--Since it is a "unit price per tsubo", the constant 3.Insert 30578.

SELECT * FROM rands WHERE price / m2 * 3.30578 < 1000000 ;

This time I made a table and started by inserting data, If the data is accumulated,

SELECT *FROM table name WHERE condition;

You can get it at. that's all.

Recommended Posts

Use WHERE to retrieve the result calculated using the Mysql syntax
[Ruby On Rails] How to update the calculated result to an integer type column using update_column
How to use the link_to method
How to use the include? method
How to use the form_with method
[Swift] Another way to use Result?
[Java] How to use the File class
[Java] How to use the hasNext function
[Java] How to use the HashMap class
[Rails] How to use the map method
[Java] How to use the toString () method
Studying how to use the constructor (java)
[Processing × Java] How to use the loop
How to use MySQL in Rails tutorial
Connect from Java to MySQL using Eclipse
[Processing × Java] How to use the class
[Processing × Java] How to use the function
[Java] How to use the Calendar class
Use the where method to narrow down by referring to the value of another model.
How to play MIDI files using the Java Sound API (specify the MIDI device to use)