![](/img/trans.png)
[英]SELECT Schema.Table.Column -> Column from another table WHERE
[英]Select data where column from table is different from column from another table
我需要從一個表(table1)中選擇數據,其中特定列不同於另一個表(table2)中的另一列
像這樣:
SELECT * FROM table1 WHERE table1.column1 != table2.column2
我做這樣的改變:
SELECT * FROM table1
inner join table2 on table1.id = table2.id
WHERE table1.column1 != table2.column2
我有一個存儲一些人的表(table1)。我需要一個一個地選擇一個隨機對象,然后添加到另一個表(table2)。如果添加了一個人,則可以再選擇一次該人,直到所有的人都被選中為止。選擇。 這是我的查詢:
SELECT * FROM people inner join people_generated on people.id = people_generated.id WHERE people.id != people_generated.id_people ORDER BY RAND() LIMIT 1
這將返回空結果:“ MySQL返回了空結果集”
第二個表“ people_genrated”為空,因此仍要生成人員。為什么結果為空?
嘗試這樣的事情
SELECT t1.name FROM table1 t1
LEFT JOIN table2 t2 ON t2.name = t1.name
WHERE t2.name IS NULL
嘗試這個,
SELECT * FROM table1
inner join table2 on table1.id = table2.id
WHERE table1.column1 != table2.column2
試試這個。
Select rooms.single from rooms where rooms.single<>checkin.room_no;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.