Jump to content

Recommended Posts

this is my query:
[code]
$sql= "SELECT avatars.id, series, active, wallpapers.id, series, active, pngs.id, series, active, layouts.id, series, active FROM avatars, wallpapers, pngs, layouts WHERE  active='1' ORDER BY `series` ASC";
[/code]

But it doesn't seem to work, what is wrong with it?
which table is "active" in?  you need to be very specific with MySQL, otherwise your statement becomes ambiguous and impossible to accurately fetch.

in the interest of properly solving this (and leaving you with useful knowledge), what exactly are you trying to pull and from which tables?
'active' is in ALL of the tables

And, I am trying to pull the series name from each table, but I want to make it where the series name will not repeat. I also want the series' to sort with eachother, so there won't be a boundry between the tables.

EX:

I want it to go like:
Series 1
Series 2
Series 3

NOT:
Series 1
Series 2
Series 1
Series 2
Series 1
Series 2
Series 1
Series 2

-------------
I still don't understand though, could someone please help me with this specific line?:

[code]
$sql= "SELECT avatars.id, series, active, wallpapers.id, series, active, pngs.id, series, active, layouts.id, series, active FROM avatars, wallpapers, pngs, layouts WHERE  active='1' ORDER BY `series` ASC";
[/code]
the easiest way to do this is to go one table at a time, one query for each table:

[code]SELECT id, series, active FROM avatars WHERE active='1' ORDER BY series ASC[/code]

i don't see any reason for you to try and grab all of the info in one query, as that only complicates everything.  reserve your multiple table queries for queries that actually require the correlation of table values (ie. where one value is dependent upon a value from a different table).

nonetheless, for the record, your problem is that you're not enunciating where each of those fields are to come from.  put properly, your query should be:

[code]$sql= "SELECT avatars.id, avatars.series, avatars.active, wallpapers.id, wallpapers.series, wallpapers.active, pngs.id, pngs.series, pngs.active, layouts.id, layouts.series, layouts.active FROM avatars, wallpapers, pngs, layouts WHERE avatars.active='1' ORDER BY `series` ASC";[/code]

however, this query will not at all do what you want it to do.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.