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.
MySQL ServerSQL* php mysqli connection

Avatar of undefined
Last Comment
Peter Chan

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Peter Chan

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck