MySQL: Select multiple rows containing values from one column -
MySQL: Select multiple rows containing values from one column -
i'd find car_id's of cars have 'ford' , 'silver' , user input value of '200' in value column:
table_cars +----+--------+----------+-----------+ | id | car_id | name | value | +----+--------+----------+-----------+ | 1 | 1 | create | ford | | 2 | 1 | carline | fiesta | | 3 | 1 | color | silver | | 4 | 1 | topspeed | 210km/h | | 5 | 2 | create | ford | | 6 | 2 | carline | focus | | 7 | 2 | color | silver | | 8 | 2 | topspeed | 200km/h | | 9 | 3 | create | holden | | 10 | 3 | carline | astra | | 11 | 3 | color | white | | 12 | 3 | topspeed | 212km/h | +----+--------+----------+-----------+ which in case should homecoming 1 car_id: car_id = 2.
what way go create sql query this?
what have properties table. when want test multiple properties @ 1 time need bring together table itself:
select c0.car_id table_cars c0 bring together table_cars c1 on c1.car_id=c0.car_id bring together table_cars c2 on c2.car_id=c1.car_id c0.name='make' , c0.value='ford' , c1.name='color' , c1.value='silver' , c2.name='topspeed' , c2.value='200km/h' having surrogate id nowadays in properties table questionable. doesn't seem doing anything; each property isn't entity of own. unless id required other element, i'd rid of , create car_id, name primary key (a composite primary key).
mysql select
Comments
Post a Comment