NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page [PHP/MySQL] Need help with a query

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
5 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 02-06-2010, 04:11 PM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Apr 2006
Location: Central PA
Posts: 101
NonProphet is on a distinguished road
 



Question [PHP/MySQL] Need help with a query


Hey everyone I was wondering if anyone could help me figure out a query for a PHP Script I'm working on. I'm writing a script that lets the user make imaginary bets on sporting events and I need to find an efficient way to do something.
????: NamePros.com http://www.namepros.com/programming/638375-php-mysql-need-help-with-query.html

I've got 2 tables, one for wagers and one for combo wagers. One of the wager fields is combo_id which is always 0 unless it is a combo wager then I put in the ID of the combo wager from the combo wager table.

The wager table contains the following fields:
wager_id
line_id
oppline_id
odds
amount
combo_id

The combo table contains the following fields:
combo_id
odds
amount

I put all wagers in the wager table, but if it is a combo wager then I place a new record in the combo table and get the combo_id, I then set the combo_id of the individual wagers.

Once the combo wager is placed I need to query the wager table and get the following results: wagers where the line_id's are equal to the oppline_id from an array, and all results must have the same combo_id.

Im basically trying to query the database to see if there is another combo bet placed where the wagers have the opposite lines selected.

Any help would be greatly appreciated, I'm stumped!
Thanks
NonProphet is offline   Reply With Quote
Old 02-06-2010, 04:57 PM   #2 (permalink)
Tech Support
Join Date: Mar 2005
Posts: 4,944
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
If I'm understanding you correctly...

Code:
SELECT *
FROM wager_table AS wager
LEFT JOIN combo_table AS combo ON(wager.combo_id = combo.combo_id)
WHERE wager.combo_id > 0
	AND wager.line_id = wager.oppline_id
although, the "from array" part, what exactly do you mean by that? got an example?
Eric is offline   Reply With Quote
Old 02-06-2010, 05:03 PM THREAD STARTER               #3 (permalink)
NamePros Member
Join Date: Apr 2006
Location: Central PA
Posts: 101
NonProphet is on a distinguished road
 



Thanks for the response.

I've got an array of line_id's (one for each wager), and id like to go through and try to find a combo wager with all the opposite line_ids being wagered on.

Edit: I think I got it all working now, thanks for the help.
Last edited by NonProphet; 02-07-2010 at 01:50 PM. Reason: Problem Solved
NonProphet is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 02:34 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger