Results 1 to 2 of 2

Thread: joining 2 tables

  1. #1
    Join Date
    Feb 2006

    joining 2 tables

    This may well be a very simple problem, but it's proving to be a stumbling point for me. I have two tables that I want to query. They contain the following columns:

    user_id (primary key)
    user_name (primary key)

    post_id (primary key)

    Both columns in the USER table have been given primary key status (is this allowed?) because user_id is an automated integer and I can join the 2 tables by using POST.user_name as a foreign key to the USER.user_name primary key.

    I would like an SQL statement that can do the following:

    1. When a person enters a string (in this case a full URL), it filters the recordset by only selecting data with the same URL. So something like this perhaps....

    WHERE POST.post_url LIKE 'colname'

    ( colname = $_GET['SearchString'] )

    2. Returns the remaining set of USER.user_name and USER.user_id values.

    I hope I've included enough information so some of you can suggest some help.

    Many thanks,


  2. #2
    Join Date
    Aug 2005
    The Garden State
    they're individually the primary keys? no. you should have only 1 primary key in the table (or a combination of columns that form a primary key). You can make user_name unique, which is fine. You'll have better performance if you just use the id, but that's fine.

    I'm not sure what your question has to do with joining tables, could you explain a little bit more.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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