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
https://forums.phpfreaks.com/topic/224437-select-select-count/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.