HighDots Forums  

Need help writting advanced query.

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Need help writting advanced query. in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Saw_duuhst
 
Posts: n/a

Default Need help writting advanced query. - 09-22-2008 , 05:51 AM






I am trying to make a column of a dynamic table display a record count from a
diffrent table, limited by the Id number from the first table....

The dynamic table displays all records of mysql table `List`
List.id
List.name

I have a second mysql table `index`.
One of the columns of `index` is named Number and contains a number that
corosponds to a List.id record.

I have added a new column to the dynamic table
List.id | List.name | new column

I would like this new column to be a number. Which is the number of records in
mysql table `index` that contain the List.id of that row...

Currently I can limit the recordset query by a entered value..1,2,3 etc...
But I do not know how to filter or limit by the List.id of the current row...

I tried this advanced query to no use...as it is not valid.
SELECT *
FROM `index`
WHERE Number = `List`.id

Thank you in advance for looking and for any help anyone can give.
Saw


Reply With Quote
  #2  
Old   
Dooza
 
Posts: n/a

Default Re: Need help writting advanced query. - 09-22-2008 , 06:00 AM






Saw_duuhst wrote:
Quote:
I am trying to make a column of a dynamic table display a record count from a
diffrent table, limited by the Id number from the first table....

The dynamic table displays all records of mysql table `List`
List.id
List.name

I have a second mysql table `index`.
One of the columns of `index` is named Number and contains a number that
corosponds to a List.id record.

I have added a new column to the dynamic table
List.id | List.name | new column

I would like this new column to be a number. Which is the number of records in
mysql table `index` that contain the List.id of that row...

Currently I can limit the recordset query by a entered value..1,2,3 etc...
But I do not know how to filter or limit by the List.id of the current row...

I tried this advanced query to no use...as it is not valid.
SELECT *
FROM `index`
WHERE Number = `List`.id

Thank you in advance for looking and for any help anyone can give.
Saw
You need to combine the 2 tables using a JOIN and then use a GROUP BY
with a COUNT in the SELECT.

Try this:

SELECT list.List.id, list.List.name, COUNT(index.List.id) AS ListCount
FROM index INNER JOIN list ON index.List.id = list.List.id
GROUP BY list.List.id, list.List.name

Dooza


Reply With Quote
  #3  
Old   
Dooza
 
Posts: n/a

Default Re: Need help writting advanced query. - 09-23-2008 , 03:57 AM



Saw_duuhst wrote:
Quote:
thanks!
Did it work?

Dooza


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.