Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

aliases not working

Status
Not open for further replies.

jez

Programmer
Apr 24, 2001
370
VN
Hi there,

I am trying to query two tables at once using simple table aliases but I am not getting results nor errors.
It is almost as if the query is run but matching 0 rows.

Heres the SQL:-

SELECT * FROM mmClients c, mmNotes n WHERE c.town LIKE '%hove%';

This is a generated from a php script where there it is likely to be more conditions in the where clause.
I have run the SQL through my php script and also through phpMyAdmin and the same thing happens...nothing.

I tried removing the aliases and then running it on only one table and records were returned (I am using test data where i know certain values exists ... ).

Is it possible that aliases are disabled ?
I also tried using AS to show the aliases (as per mySql documentation) but the same happened.

Any tips would be great....
[afterthought]
do you have to lock tables to use aliases, even for a read query
[/afterthought]


Many thanks

JEz
 
OK, I have found the problem...just posting here as it is fairly simple but might help someone.

The situation is this....i designed and built the app and am currently debugging.
Data is test data, but in my oversight i did not fill the 'notes' table with any info - i.e. rows 0

SO, an alias doesnt work if there are no rows in one of the tables (i guess because there is no use for an alias to an empty table because there is nothing to join on).

SO my problem is solved and hopefully this will something else.


Thanks anyway folks.

JEz


:):):)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top