This is a discussion on "Foreign Key references some" within the Databases section. This forum, and the thread "Foreign Key references some are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Foreign Key references some
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
||||
|
||||
|
Foreign Key references some
Is there anyway to have a column reference the amount of rows of another table based on a where?
Something like:
Thanks.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
|
|
#2
|
||||
|
||||
|
Re: Foreign Key references some
Alex, I actually did this with PHP... Not 100% sure if it is possible with just a SQL statement.
What I did was I selected the count from the table I wanted and then saved that to a variable, then I added that to the corresponding row in another table. So I used 2 SQL statements to do it really, just used PHP to hold the variable.
Last Blog Entry: Happy Holidays - A Non Offensive way to say Merry Christmas? WRONG! (Dec 11th, 2007)
|
|
#3
|
||||
|
||||
|
Re: Foreign Key references some
Yeah the point was that I didn't want to have to query twice.
If there's no way to do this on the mysql side I'll have to resort to two queries.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
#4
|
||||
|
||||
|
Re: Foreign Key references some
The only way that I could fathom it could be done in one query is if you used a Select Into and somehow got it to return the count instead of the data. I've searched the internet for the answer and haven't found anything yet though. I'll keep playing around with it and if I find a solution I'll post it back.
Last Blog Entry: Happy Holidays - A Non Offensive way to say Merry Christmas? WRONG! (Dec 11th, 2007)
|
|
#5
|
||||
|
||||
|
Re: Foreign Key references some
I guess I could just do select * from tbl, othertbl or some sort of left join anyway.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I design for a foreign language? | mreine | Web Page Design | 6 | Dec 28th, 2005 15:51 |
| Foreign Key's adjacent, descriptive fields need updating - How To? | jswebdev | PHP Forum | 0 | Dec 10th, 2005 21:31 |