LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[Webdev] SQL question

[Webdev] SQL question

Martin kitten at psophos.com
Thu Aug 31 00:12:38 IST 2000


> :>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.

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.
Otherwise don't.

> :>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;

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
revised.
Some of this stuff is more art than science (well it seems that
way at times :-). Good luck.

Martin




More information about the Webdev mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


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!
RSS Version
Powered by Dell