0

I have a table where I need to do two selections. First I need to find OBJ where uunn = abc. Then I need to select where OBJ equals the first result but it doesn't work.

Example:

SELECT OBJ INTO @obj FROM wddt WHERE `uunn`='abc' AND `mqr`='ps';
SELECT mqr FROM wddt WHERE `OBJ` = @obj AND `uunn`='as';

My goal is to check if mqr has a certain content, and I will compare that content in my PHP script.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Sander
  • 23
  • 7

2 Answers2

1

Multi_query was disabled on the server I was trying to use, just tested everything using XAMPP and works like a charm. I didn't know multi-query could be disabled.

Sander
  • 23
  • 7
0

If you don't need the actual results of the first query you may use a subquery in the WHERE clause of the second one:

SELECT mqr FROM wddt WHERE `uunn`='as'
 AND `OBJ` LIKE (SELECT OBJ FROM wddt WHERE `uunn`='abc' AND `mqr`='ps');
Erick
  • 301
  • 3
  • 12