NameSilo

[PHP/MySQL] Need help with a query

Spaceship Spaceship
Watch

NonProphet

Established Member
Impact
2
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.

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
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
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?
 
0
•••
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:
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back