Link to home
Start Free TrialLog in
Avatar of Web IT
Web IT

asked on

Is it possible to set a mysql query as a variable ?

Imaging you have an basic statment
SELECT  *  FROM   post_id WHERE  wp_postmeta =2;

Open in new window

I know the
SET @variable. command but I want to set the whole statment do I have to use functions ?
or is there a way (which I tried) such as:

SET @variable = (SELECT  *  FROM   post_id WHERE  wp_postmeta =2);

Open in new window

then I can run the command using
SELECT @variable.
ASKER CERTIFIED SOLUTION
Avatar of Peter Chan
Peter Chan
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial