* Thus wrote Dave Carrera ([EMAIL PROTECTED]):
> Hi List,
> 
> I am trying to make a search box for my site and I ask the list how can I
> search 24 tables to find a search string posted by a form.

oohh.. ouch ;)

> 
> I get Column: 'listing' in where clause is ambiguous when I run 
> 
> $sql = mysql_query("select * from $tbs where listing like
> \"$_POST[tglstring]\"") or die(mysql_error());
>       
> $tbs is a string containing 24 table names (1 for each letter of the
> alphabet).

You cant search tables like that and get back what your expecting.
If you have two tables say:

  create table t1 {
    id int,
    name  varchar(50)
  )
  create table t2 {
    id int,
    name  varchar(50)
  )


If you select from both of those tables like:
  select * from t1, t2

The field list returned from mysql will be:
  id, name, id, name

And If you add a condition to the sql statement:
  select * from t1, t2 where name like 'foo%'

Mysql complains about ambiguous column, because It has no idea from
which table you want 'name' to be like. And even if you did tell it
what tables too look at:

  select * from t1, t2 where t1.name like 'foo%' or t2.name like
  'foo%'

Your data is going to be all messed up anyway. You can use a UNION
statment to fix this problem or restructure your data so you dont
have this problem, the later being prefered method.

You should get on the mysql mailing list. I think i've already said
to much about mysql.

Curt.
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to