> :>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
To make the search quicker you could put an index on every
column in the table. Not recommended though. Searching is nice &
fast but inserting data is painfully slow as all the indexes
must be updated too.
You could do it if you must search every field in the table &
the data in the table is static, or changes very little.
> :>Or for that matter, is there a simple way of searching more than one
>> 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 =
>> 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 =
A join/2/3 may help you. If you have to search every field in
the table then the design of the table/database may need to be
Some of this stuff is more art than science (well it seems that
way at times :-). Good luck.
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!