Results 1 to 2 of 2

Thread: sql query

  1. #1
    Join Date
    Apr 2004
    Posts
    6

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

  2. #2
    Join Date
    Jan 2004
    Posts
    492

    Re: sql query

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •