Jump to content

Select & Select Count


smti

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.