Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Haider's avatar

Database Joins query problem

SQL Server shows output on this query

Select * from Vehicle_details, Vehicle_specifications, Vehicle_rent_specs;

but not on the query having joins

Select vd.VIN_number, vd.Name, vd.Manufacturer, vd.VehicleType, vs.EnginePower, vrs.CostPerDay, 
vrs.Availability from Vehicle_details vd inner join Vehicle_specifications vs on vd.id = vs.vehicle_details_id 
inner join Vehicle_rent_specs vrs on vd.id = vrs.vehicle_details_id;

Anyone figured out the problem in it, please help.

0 likes
2 replies
Qlic's avatar

Probably because the inner join can't find a matching record. You should look into leftJoin as that will always return the main table even if the joins contain no matching data.

Also, you should look in to the laravel naming conventions, since uppercase characters in your table/field names should be avoided.

Dunsti's avatar

the syntax select * from table1, table2 produces a STRAIGHT_JOIN.

from the MySQL-Documentation:

STRAIGHT_JOIN is similar to JOIN, except that the left table is always read before the right table. This can be used for those (few) cases for which the join optimizer processes the tables in a suboptimal order.

see here: https://dev.mysql.com/doc/refman/5.7/en/join.html

Please or to participate in this conversation.