My Table structure is given below
id user_name item brand
1 A car ferrari
2 A bike suzuki
3 B car ferrari
4 B bike yamaha
Here I want to write a select query for user_name having car ferrari and bike suzuki. Please help me to write sql Query
This should do the trick:
However you should consider to improve your database schema (store
vehiclesin another table, and have a relational tableusers_vehiclesmaybe)