I have never seen this before.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Steji
Forum Newbie
Posts: 19
Joined: Fri Jun 18, 2010 6:06 am

I have never seen this before.

Post by Steji »

"SELECT ph.*, p.price, s.width as widthin, s.height as heightin, m.name as material, d.width as frame_width, d.depth as frame_depth FROM photograph"

Just an example of what I'm looking at, what I don't understand is the prefixed table columns. It must be for other tables in the database as none of these columns are in the table photograph so why have FROM photograph in the query? Also there is more than one table beginning with 's' so how is s.height found when it could be in one of two tables?

Thanks
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: I have never seen this before.

Post by Benjamin »

It appears the rest of the query is missing. Those are simply aliases.

Code: Select all

select ph.* from some_table ph where ph.foo = 'bar'
That assigns ph as an alias of some_table.
Steji
Forum Newbie
Posts: 19
Joined: Fri Jun 18, 2010 6:06 am

Re: I have never seen this before.

Post by Steji »

Code: Select all

"SELECT ph.*, p.price, s.width as widthin, s.height as heightin, m.name as material, d.width as frame_width, d.depth as frame_depth FROM photograph ph, poster_print_prices p, sizes s, frames f, material m, dimensions d WHERE (ph.session_id='$sessionid' or (ph.user_id = '$userid' and ph.user_id > 0)) and ph.order_id='0' and p.id = ph.price_id and m.id = f.material_id and f.dimensions_id = d.id";
I can't see where the other aliases are defined like d or s?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: I have never seen this before.

Post by AbraCadaver »

Steji wrote:

Code: Select all

"SELECT ph.*, p.price, s.width as widthin, s.height as heightin, m.name as material, d.width as frame_width, d.depth as frame_depth FROM photograph ph, poster_print_prices p, sizes s, frames f, material m, dimensions d WHERE (ph.session_id='$sessionid' or (ph.user_id = '$userid' and ph.user_id > 0)) and ph.order_id='0' and p.id = ph.price_id and m.id = f.material_id and f.dimensions_id = d.id";
I can't see where the other aliases are defined like d or s?
Look harder:

FROM photograph ph, poster_print_prices p, sizes s, frames f, material m, dimensions d
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Steji
Forum Newbie
Posts: 19
Joined: Fri Jun 18, 2010 6:06 am

Re: I have never seen this before.

Post by Steji »

Thanks, I honestly don't know why I couldn't see that!
Post Reply