Here are two statements that I would like to work but that return error messages:
IF EXISTS (SELECT * FROM gdata_calendars WHERE `group` = ? AND id = ?) SELECT 1 ELSE SELECT 0
and
IF ((SELECT COUNT(*) FROM gdata_calendars WHERE `group` = ? AND id = ?) > 0) SELECT 1 ELSE SELECT 0;
There are question marks because I use parameterized, prepared instructions with PHP PDO. However, I also tried to do this with the data manually, and it really doesn't work.
Although I would like to know why each of them does not work, I would prefer to use the first query if it can be made to work.
mysql
CE Apr 3 2018-11-11T00: 00Z
source share