我有這個表在MySQL被稱爲safespot的MySQL查詢其他表狀況PHP
+---------+---------------+
| term_id | userid | safe |
+---------+--------|------+
| 1 | 1 | large number, unix timestamp here
| 1 | 2 | large number, unix timestamp here
| 1 | 3 | large number, unix timestamp here
| 1 | 4 | large number, unix timestamp here
+---------+--------+
這是表users
:
+----+-------------+-------------+
| id | userid | cash |
+----+-------------+-------------+
| 1 | 1 | 100000 |
| 2 | 2 | 100000 |
| 3 | 3 | 100000 |
+----+-------------+-------------+
我怎麼可以這樣做
SELECT * FROM `users` where `userid`=1 and `cash`>= 1000 and " userid do not exist in table safespot" or "if the user exists in the safestop table, check if the current timestamp is higher than the safe colum)
所以基本上做一個查詢,也會返回它,如果userid不存在於保險箱表中,或者如果它存在,那個時間戳高於safe_value。
但是,它也必須具備條件,它存在於另一個表中,它必須檢查安全值,因此它比當前時間戳更大? – maria
對不起,我更新了我的答案;-) –