![]() |
|
#1
|
|||
|
|||
sql helpHi guys,
I am having some problems in writing a sql query for search.My case is as given below I have two tables books(having attributes like titles,subtitles etc) and authors(having attributes first name and last name).They have a many to many relationship between them and related by books_authors table. Now I want to write a sql query such that any string provided by the user that matches the author fname,lname or books title subtitle then it must show the result. How can I achieve this using joins or any other way Seeking for help |
|||
|
#2
|
||||
|
||||
Re: sql helpThe resulting query would really depend on how well the tables are put together [normalized].
Can you post more info. [the specific fields] contained in each table, and how they are related? Also have a look at this short 'normalization' (a simplified "Mike's Bookstore") example . It might also give some ideas. __________________
Use the force...read the source!! WYCIWYG -- what you code is what you get! |
|
#3
|
|||
|
|||
Re: sql helpwell you have two different tables, and you want to determine if something someone inputs is contained in one or all of three different fields, two which are from authors, and 1 which is from books.
we'll set up your from statement first. Code:
then you can set up your select statement. Code:
and then your where clause. Code:
i think the 'books e' syntax is considered an "alias" so if you have two attributes named the same you can distinguish them by making multiple 'instances' of the two or more different tables. I hope this is what you were looking for, if not please email me at twotwohappy@hotmail.com I can try to help you further. p.s dont forget to close your whole sql statement with the ; for example: select from where; basically MonkO the 'where clause' is also assuming that your inputs correspond with the three different attributes specifically. OR's and AND's are long and drawn out, but usually the easiest way to get what you want. |
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unlimited Domain Hosting – Reselling with Windows 2003| Linux | CF MX | SQL | ASP.NET | JodoHost | Web Hosting Advertisements & Offers | 0 | 04-Apr-2007 23:08 |
| getting an error while compiling and running using different IDE. | jaro | C Programming Language | 0 | 25-Aug-2006 10:14 |
| functions seems not to exit from a certain code block | jaro | C Programming Language | 3 | 22-Mar-2006 00:08 |
| Microsoft SQL Server :: SQL Server message 241, state 1, severity 16 | lyuboe | MySQL / PHP Forum | 0 | 11-May-2005 05:31 |
| DiscountASP.NET Launches SQL Reporting Services | dasp | Web Hosting Advertisements & Offers | 0 | 19-Oct-2004 18:32 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The