i have problem while selecting table_name
A B C
2 ab ab
2 bc bc
3 ac ac
4 as as
this is my table and i want to execute
select * from table_name
only when it has more than 0 rows.
if count(*) table_name >0 i dont want to print table_name.
for this i tried
SELECT
CASE (SELECT COUNT(*) FROM table_name) WHEN 0 THEN "Min Row Cond not valid"
ELSE (SELECT * FROM table_name AS abc )
END
but i am getting
Error Code : 1241
Operand should contain 1 column(s)
2) sencond time i tried for
IF (SELECT COUNT(*) FROM Table_name) > 0
BEGIN
SELECT * FROM Table_name
END
ELSE
BEGIN
Print 'Min Row Cond not valid'
END
then i got Error Code : 1064
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 'IF (SELECT COUNT(*) FROM Table_name) > 2
BEgin
SELECT * from Table_name
END
ELSE
BEGIn' at line 1
how to solve this problem
thank you
A B C
2 ab ab
2 bc bc
3 ac ac
4 as as
this is my table and i want to execute
select * from table_name
only when it has more than 0 rows.
if count(*) table_name >0 i dont want to print table_name.
for this i tried
SELECT
CASE (SELECT COUNT(*) FROM table_name) WHEN 0 THEN "Min Row Cond not valid"
ELSE (SELECT * FROM table_name AS abc )
END
but i am getting
Error Code : 1241
Operand should contain 1 column(s)
2) sencond time i tried for
IF (SELECT COUNT(*) FROM Table_name) > 0
BEGIN
SELECT * FROM Table_name
END
ELSE
BEGIN
Print 'Min Row Cond not valid'
END
then i got Error Code : 1064
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 'IF (SELECT COUNT(*) FROM Table_name) > 2
BEgin
SELECT * from Table_name
END
ELSE
BEGIn' at line 1
how to solve this problem
thank you