Results 1 to 4 of 4

Thread: data from2tables

  1. #1
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default data from2tables

    hi,
    i have 2 tables,data is stored and i want to retrieve data from 2 tables in a single query, is it possible to achiev it?

    table 1
    id - visit
    1
    2
    3
    .
    3
    2
    3
    .
    .


    -------------------

    table 2
    id - meeting
    1
    2
    3
    4
    1
    2
    3
    4
    .
    .
    .
    ---------------

    tables are just like this, both IDs are having samelike value.
    nowiwant to get the IDS of those 5 persons who have more visits and meeting,but i want in a single query...plz help

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The easiest way to do any of this (more than one table) is to just take it one step at a time and then query again in PHP to narrow it down. There may be complex ways in mysql, but php would probably be easier to work with, if a little slower (doing multiple, bigger queries).
    So, get all the meetings. Then get all the visits. Then compare the two in PHP and see what you get.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    Quote Originally Posted by djr33 View Post
    The easiest way to do any of this (more than one table) is to just take it one step at a time and then query again in PHP to narrow it down. There may be complex ways in mysql, but php would probably be easier to work with, if a little slower (doing multiple, bigger queries).
    So, get all the meetings. Then get all the visits. Then compare the two in PHP and see what you get.
    yes its easy...

    but i want to calculate the data on back end, if i compare it with PHP and the result is not satisfactory then again i have so send more queries to get more data...

    so i want to compare and get data from two tables at a time b after comparing on the back end...

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    If you must do it with mysql, then take a look here:
    http://www.tizag.com/mysqlTutorial/mysqljoins.php

    The problem is that while you may be able to setup a basic mysql-only script, if you ever need to modify it things can get very complex. I hope that tutorial at least gets you started.

    Also, I do think this could be done well in php (maybe not quite as efficiently), if you make sure you don't need to query again afterward.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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