If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > sql query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-06-04, 18:24
louphp louphp is offline
Registered User
 
Join Date: Apr 2004
Posts: 6
sql query

Hi,
I'm trying to write a query that when a user enters a search term in a text box such as Computing, it will then check whether there are any adverts available with Computing in their title.

The tables are:

advert2
(advert_id, username, mod_book_id, asking_price, condition, description, date_added)

ts_module_books
(id, module_code, essential_useful, author, book_title, publisher, pub_year)

the query im using is:

"select * from ts_module_books inner join advert2 on advert2.mod_book_id = ts_module_books.id where ts_module_books.book_title LIKE '%$search%'"

However, what i want outputting to the page is

book_title, author and publisher from ts_module_books,
and also user from the advert2 table.

Is this possible? And if so, how do i do this?

Thanks.

Lou
Reply With Quote
  #2 (permalink)  
Old 04-06-04, 19:21
ss659 ss659 is offline
Registered User
 
Join Date: Jan 2004
Posts: 492
Re: sql query

Quote:
Originally posted by louphp


"select * from ts_module_books inner join advert2 on advert2.mod_book_id = ts_module_books.id where ts_module_books.book_title LIKE '%$search%'"


book_title, author and publisher from ts_module_books,
and also user from the advert2 table.
Code:
select ts.book_title, ts.author, ts.publisher, a.user
from ts_module_books ts, advert2 a
where a.mod_book_id = ts.id
and ts.book_title like '%$search%'
Hope this is what you're after
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On