smti Posted January 14, 2011 Share Posted January 14, 2011 Hello, I am a bit stumped as to how I can combine a select and select count statement together. I need to select fields from one table and count the number of records in another table using one of the fields from the first table's results. My table structure is as follows: Trackchasers contains the following fields: 1. cid 2. cfn 3. ccitty 4. rgid 5. ctid Both the trackchasers and trackvisits tables share the cid field. I am able to execute queries individually to get some of the data I need, however, I need to combine these queries if possible so it is easier to work with in PHP. My selection query: select cid, cfn, cln, ccity, rgid, ctid from trackchasers My count query: select count(cid) as trackvisits from trackvisits where cid=12; How can I combine these two statements to display all the fields I need plus the counting code? I tried using an inter join query, but had little luck. Thanks for any help you can provide! -smti Quote Link to comment Share on other sites More sharing options...
fenway Posted January 14, 2011 Share Posted January 14, 2011 Show us the join you had. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.