我们公司的mysql数据库,就一个同事的数据库执行错误,其他人的都可以
sql语句是这样的:
SELECT id, `name`, camp, `level`, sex, loveValue,
IF(EXISTS((SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 0 AND owner_type = 1 LIMIT 1)),
(SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 0 AND owner_type = 1 LIMIT 1),0) AS weapon,
IF(EXISTS((SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 2 AND owner_type = 1 LIMIT 1)),
(SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 2 AND owner_type = 1 LIMIT 1),0) AS coat
FROM player_gamedata
WHERE isDelete=0 AND loveValue>0
ORDER BY loveValue DESC, id LIMIT 5报错是这样的:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND locat' at line 2
sql语句是这样的:
SELECT id, `name`, camp, `level`, sex, loveValue,
IF(EXISTS((SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 0 AND owner_type = 1 LIMIT 1)),
(SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 0 AND owner_type = 1 LIMIT 1),0) AS weapon,
IF(EXISTS((SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 2 AND owner_type = 1 LIMIT 1)),
(SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 2 AND owner_type = 1 LIMIT 1),0) AS coat
FROM player_gamedata
WHERE isDelete=0 AND loveValue>0
ORDER BY loveValue DESC, id LIMIT 5报错是这样的:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND locat' at line 2
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND locat' at line 2
从错误提示看应该版本问题。
IFNULL((SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 0 AND owner_type = 1 LIMIT 1),0) AS weapon,
IFNULL((SELECT item_data_id FROM r_itemdb WHERE owner_id = player_gamedata.id AND location = 6 AND cell = 2 AND owner_type = 1 LIMIT 1),0) AS coat,
FROM player_gamedata
WHERE isDelete=0 AND loveValue>0
ORDER BY loveValue DESC, id LIMIT 5