我有这个问题:
SELECT 'events' AS tbl,events.*, users.name, users.lastname,
(SELECT COUNT(*) FROM events_participants WHERE
events_participants.eventid=events.id) AS participants
FROM
(events INNER JOIN users ON users.id=events.organizer)
WHERE events.isConfirmed<=1
AND events.category='art&culture'
AND events.city='Roma(Rm)'AND events.datetime >= '2011/02/22 22:30'
AND events.datetime<='2011/06/22 23:00' ORDER BY events.datetime DESC
&&
中的&符号art&culture
会导致查询不返回行。
答案 0 :(得分:0)
如果这是完整查询,看起来'2011/06/22 23:00'和ORDER BY之间应该有空格
答案 1 :(得分:0)
可能的问题:
datetime
是保留字。尝试将events.datetime
替换为events.`datetime`
,无论它出现在哪里。答案 2 :(得分:0)
在MySQL中,您可以在文本字段中搜索&符号,如下所示:
mysql> create table yar (id INT, mytext TEXT);
Query OK, 0 rows affected (0.02 sec)
mysql> insert into yar values(1, 'art&culture');
Query OK, 1 row affected (0.00 sec)
mysql> select * from yar;
+------+-------------+
| id | mytext |
+------+-------------+
| 1 | art&culture |
+------+-------------+
1 row in set (0.00 sec)
mysql> select * from yar where mytext = 'art&culture';
+------+-------------+
| id | mytext |
+------+-------------+
| 1 | art&culture |
+------+-------------+
1 row in set (0.00 sec)