خرید بک لینک

Vote count: 0

I have to tables: user and userimages. enter image description here

Right now, I'm using the following query:

SELECT *  FROM   users u INNER JOIN userimages ui ON u.id=ui.userid;

Yes. It retrieved the records if the userid and id is equal. What I really want to do is to select all records from table users even if its id is not present on the second table (userimages)

My question is how to select all records in the users table with or withou userid on the second table?

asked 4 mins ago

1 Answer

Vote count: 0

You're looking for a LEFT JOIN, which will pull all rows from the first table and join where applicable to the right.

SELECT *  FROM   users u LEFT JOIN userimages ui ON u.id=ui.userid;

answered 42 secs ago

برچسب: mysql select all records,mysql select all records not in another table,mysql select all records from today,mysql select all records from yesterday,mysql select all records from one table and some from another,mysql select all records between two dates,mysql select all records from two tables,mysql select all records in a table,mysql select all records for current month,mysql select all records when no value is supplied, نویسنده: استخدام کار تاريخ: شنبه 23 مرداد 1395 ساعت: 2:23

صفحه بندی