我有这个表在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
对不起,我更新了我的答案;-) –