-1

I want to combine two queries to make them act as single query

there are NO unique columns in both the tables

My two queries

SELECT * from admin WHERE name != 'xyz'
Select goods from good_items where userid=$userid

with single query I am getting the results fine . but two queries combined i get this error

mysql_fetch_array() expects parameter 1 to be resource, boolean given in

I am combining the queries like this

 $sqlofferadmin=mysql_query("SELECT name,task,prize from admin WHERE name != 'xyz' 
    UNION ALL 
    SELECT goods from good_items WHERE userid=$userid");

I want to display out like this

<?php 
 while($row = mysql_fetch_array($sqlofferadmin))  
{

    echo "<tr> ";
    echo "<td>" .$row[name] . "</td>";
    echo "<td> ".$row[task] . "</td>";
    echo "<td>" .$row[goods] . " </td>";
 }
     echo "</tr> " ;
  ?>
nasima
  • 11
  • 5

1 Answers1

0

This should help you:

    $sqlofferadmin=mysql_query("SELECT name,task,prize,goods from admin a, 
goods g WHERE a.unique_column = g.unique_column and name != 'xyz' and userid=$userid");

But the above is only valid if you have a relation in 2 tables.

Fakhruddin Ujjainwala
  • 2,463
  • 16
  • 26