Results 1 to 5 of 5
  1. #1

    Question Selecting data from two different tables in phpmyadmin


    I have two tables,

    A = Client table (client_id, client_name fields)
    B = History table (amount field)

    I want to select all clients from Client tables who have any record/amount in History Table.

    Please let me know how to do this?

    Thank you


  2. #2
    Join Date
    Mar 2005
    Athens, Greece
    You should have an associated key for both tables. A: client_id, B:client_id
    Antonis Adamakos @ FuzzFree :: Fully Managed Web Hosting, Development, Online Marketing

  3. #3
    Join Date
    Mar 2004
    Chennai India
    run this query in phpmyadmin

    SELECT,history.amount FROM HISTORY LEFT JOIN client ON client
    .client_id = history.client_id
    miOOt Chat Solutions
    live chat Software for web hosting Customer Service
    Importance of Live Chat Software for Web Hosting Business

  4. #4
    Join Date
    Aug 2001
    Orange County, CA
    If there's always going to be a foreign key on 'client_id' between the tables you should use an INNER JOIN rather than a LEFT JOIN. The latter will also include rows which don't exist in both tables (a client without history rows, or orphaned history rows with no client).
    Jeff Standen, Chief of R&D, WebGroup Media LLC. - LinkedIn
    Cerb is a fast and flexible web-based platform for business collaboration and automation.

  5. #5
    Join Date
    Apr 2009
    It is always better to use a foreign key in table B if you dont have one there. Also use inner join ie (where instead of left join to avoid unnecessary records.

    You can run the sql query in phpmyadmin using the editSQL option

Similar Threads

  1. Selecting Random Rows from two different tables
    By jon31 in forum Programming Discussion
    Replies: 4
    Last Post: 12-08-2005, 05:15 PM
  2. Can't browse tables with phpMyAdmin
    By donnyboy in forum Hosting Security and Technology
    Replies: 4
    Last Post: 09-09-2004, 07:03 AM
  3. MYSQL help need: Selecting from 3 tables
    By null in forum Programming Discussion
    Replies: 11
    Last Post: 09-02-2004, 09:21 PM
  4. adding back what you've dropped for tables in phpmyadmin
    By HopelessLose in forum Programming Discussion
    Replies: 4
    Last Post: 03-28-2004, 09:07 PM
  5. adding multiple tables PHPMyadmin
    By tonkagunner in forum Programming Discussion
    Replies: 3
    Last Post: 09-06-2003, 10:31 PM

Posting Permissions

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