Web Design and Development Forums

Foreign Key references some

This is a discussion on "Foreign Key references some" within the MySQL section. This forum, and the thread "Foreign Key references some are both part of the Databases category.


Go Back   Webforumz.com > Databases > MySQL

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old Jan 30th, 2008, 22:21   #1 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
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:
Code: Select all
create table tbl (
[columns here]
amount int(100) REFERENCES othertbl(COUNT(*) FROM othertbl GROUP BY column)
)
It's hard to explain what I mean, but that example should help.
Thanks.
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 31st, 2008, 05:05   #2 (permalink)
 
JustinStudios's Avatar
 
Join Date: Mar 2007
Location: USA
Posts: 457
Blog Entries: 3
Send a message via MSN to JustinStudios
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.
__________________
My Website www.justudios.com is here!
Availability: YES | NO
ASP | PHP |Flash | Design | Contract Work
JustinStudios is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 31st, 2008, 15:38   #3 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
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.
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 31st, 2008, 17:05   #4 (permalink)
 
JustinStudios's Avatar
 
Join Date: Mar 2007
Location: USA
Posts: 457
Blog Entries: 3
Send a message via MSN to JustinStudios
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.
__________________
My Website www.justudios.com is here!
Availability: YES | NO
ASP | PHP |Flash | Design | Contract Work
JustinStudios is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Jan 31st, 2008, 17:14   #5 (permalink)
Administrator
 
alexgeek's Avatar
 
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 4,102
Blog Entries: 9
Send a message via MSN to alexgeek
Re: Foreign Key references some

I guess I could just do select * from tbl, othertbl or some sort of left join anyway.
__________________
Languages: PHP, mySQL (queries), C#, (X)html, CSS, JS.


alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I design for a foreign language? mreine HTML Forum 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



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 05:41.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59