![]() |
mysql JOIN challange
I have spent the last week trying to create a query that returns the data from one table in the format i want it but without success. I am sure I need to JOIN a table with itself but its the COUNTing of types of row which is proving most challenging. Wonder if anyone can help or even further resolve for me. Its a challange indeed.
Essentially I want a query that will take this table: Code:
betid customer group resultCode:
group customer Wins Losses |
Use 0 and 1 instead of "win" and "loose". Numbers are better for machines to parse. I would also use IDs for customers instead of names, attach a related table if you want info on them. I also don't see how a join statement is needed for what you have, join is for adding results from associated tables.
I wrote this off the top of my head, this should be something close to what you need. Code:
SELECT |
Building onto Village Idiot's example:
sql Code:
|
That is pretty much what i'm looking for thanks. Glad this was in the absolute beginners section as that is what i obviously am. Only issue i have is its returning th extra customer_id column which matches customer but its an extra column i dont really want to return. Any way i could adjust the query to return the 4 columns instead of the 5?
|
Naturally! :-)
sql Code:
|
Perfect! Much appreciated.
|
Quote:
|
| All times are GMT. The time now is 10:32 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0