Sign in to follow this  
Followers 0
Ealric

MySql Select Query issue

2 posts in this topic

First, I've never asked something related to another type of DB issue, but it does pertain to a query I'm trying to build inside of my autoit program and you guys are like family to me so I trust your answers more than other people. So, my apologies in advance for asking this type of question...

Okay, here's my issue. I have a database that contains data that I will need to pull from 37 different tables...

The common denominator for each table is the "Name" column.

I'm only going to be pulling comparisons for two different names at one time so as an example..

I've been using something similar which does not do what I need it to do:

Code:

CODE
Select

`3rd Down Conversion Percentage`.`Name`,

`3rd Down Conversion Percentage`.`Pct`,

`3rd Down Percentage Defense`.`Pct`,

`4th Down Conversion Percentage`.`Pct`,

`4th Down Percentage Defense`.`Pct`,

`First Downs Offense`.`PG`

From

`3rd Down Conversion Percentage`,

`3rd Down Percentage Defense`,

`4th Down Conversion Percentage`,

`4th Down Percentage Defense`,

`First Downs Offense`

Where (

`3rd Down Conversion Percentage`.Name IN ('Florida','Oklahoma')

And `3rd Down Percentage Defense`.Name IN ('Florida','Oklahoma')

And `4th Down Conversion Percentage`.Name IN ('Florida','Oklahoma')

And `4th Down Percentage Defense`.Name IN ('Florida','Oklahoma')

And `First Downs Offense`.Name IN ('Florida','Oklahoma')

)All I want to do is end up with (two rows of data) with the following:

Name|Pct|Pct|Pct|Pct|PG

Florida|..|..|..|..|..

Oklahoma|..|..|..|..

And that's it...

The problem is this pulls 32 or more rows of data somehow and sorts them in all types of crazy groupings. Even grouping by doesn't work.

I just need a working example as to how to just pull 2 rows of data everytime using the columns above. They can even be inner joined together and the column names can be changed to Pct.a, Pct.b, Pct.c, Pct.d, PG...

Thanks in advance and again my sincere apologies for posting a DB query question... I'm just stuck..


My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Share this post


Link to post
Share on other sites



I figured it out myself. I used:

$query = "Select " & _
    "`3rd Down Conversion Percentage`.`Name`," & _
    "`3rd Down Conversion Percentage`.`Pct`," & _
    "`3rd Down Percentage Defense`.`Pct`," & _
    "`4th Down Conversion Percentage`.`Pct`," & _
    "`4th Down Percentage Defense`.`Pct`," & _
    "`First Downs Offense`.`PG`" & _
"From" & _
    "`3rd Down Conversion Percentage`," & _
    "`3rd Down Percentage Defense`," & _
    "`4th Down Conversion Percentage`," & _
    "`4th Down Percentage Defense`," & _
    "`First Downs Offense`" & _
"Where (`3rd Down Conversion Percentage`.Name IN ('Florida','Oklahoma')" & _
        " And    `3rd Down Percentage Defense`.Name = `3rd Down Conversion Percentage`.Name" & _
        " And    `4th Down Conversion Percentage`.Name = `3rd Down Conversion Percentage`.Name" & _
        " And    `4th Down Percentage Defense`.Name = `3rd Down Conversion Percentage`.Name" & _
        " And    `First Downs Offense`.Name = `3rd Down Conversion Percentage`.Name" & _ 
    ")"

My Projects: [topic="89413"]GoogleHack Search[/topic], [topic="67095"]Swiss File Knife GUI[/topic], [topic="69072"]Mouse Location Pointer[/topic], [topic="86040"]Standard Deviation Calculator[/topic]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0