无法使用表2中的条件更新table1

时间:2018-02-05 11:11:57

标签: sql conditional-statements

我想用时间戳更新列lasvisit,我想加入另一个表,因为它在这个表中的条件看到我的查询:

UPDATE vld_members SET lastvisit='123456789' 
WHERE 
vld_members as m
INNER JOIN 
vld_members_data_members as md
ON  m.member_id = md.data_id 
WHERE md.data_gender1 = 1
ORDER BY RAND() LIMIT 1

但它不起作用我测试了这个:

UPDATE vld_members SET lastvisit='1517688911' 
WHERE vld_members INNER JOIN vld_members_data_members 
ON  vld_members.member_id = vld_members_data_members.data_id 
WHERE vld_members_data_members.data_gender1 = 1 ORDER BY RAND() LIMIT 2

无法正常工作

但我有2个查询工作:

SELECT * 
FROM vld_members as m 
INNER JOIN vld_members_data_members as md on m.member_id = md.data_id 
WHERE md.data_gender1 = 1 ORDER BY RAND() LIMIT 5



UPDATE vld_members SET lastvisit='.$var.' 
ORDER BY RAND() LIMIT 5

工作?

0 个答案:

没有答案