I Need to Join two tables car details and favorite cars.I used left join to join both tables.
|id| name |Model |registration |Description |Variant |status|User Detail Id
|1| Etios | Mini | 123123 |AC Available |Petrol |Active|51
|1| Etios | Mini | 123123 |AC Available |Petrol |Active|47
|1| Etios | Mini | 123123 |AC Available |Petrol |Active|52
|6| Indigo | Mini | 123 |AC Available |Gas |Active|NULL
This is the output i got but exactly what i need is to display car based on userdetailid.For userdetailid='52' i need to get 3rd and 4th row
I used this query
SELECT `u`.`id`,`u`.`CarName`,`u`.`CarModel`,`u`.`RegistrationNumber`,`u`.`Description`,`u`.`Variant`,`u`.`Status`,`uf`.`CardetailsId`,`uf`.`UserDetailsId`
FROM `cardetails` AS `u` LEFT JOIN `favoritecars` AS `uf` ON (`u`.`id` = `uf`.`CarDetailsId`)
where
u.status = 'Active' and u.CarModel = 'Mini' and (uf.UserDetailsId='52' or uf.UserDetailsId is null)
Please help me.Thanks in advance