William Murphy's [alias at eircom.net] 16 lines of dribble included:
:>Hi all,
:>:>If I want to search pretty much every field of a mysql table, do I have
:>to just to put in a big long WHERE clause or is there some quicker way?
As far as I know, yes,
SELECT * from table_name;
gives you all the fields, but if you want to do some more groovy searching
then you're going to need to stick in a conditional, like WHERE AND or WHERE
OR.
:>Or for that matter, is there a simple way of searching more than one
:>table?
There is indeed. They're called "table joins"
For example say you have the following tables
table userlist:
user id pass name email
table bookmarks:
user url desc category
SELECT bookmarks.url FROM bookmarks, userlist WHERE bookmarks.user =
userlist.user;
The above should work on most systems, but there is an ANSI SQL standard for
doing inner joins, and the proper syntax is something like...
SELECT bookmarks.url FROM bookmarks INNER JOIN userlist ON bookmarks.user =
userlist.user;
Regards,
Phil.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!