Jump to content

What does mean p., pl., g., o...etc.. in SQL queries?


Recommended Posts

Hi I want to create SQL query for SQL Manager but I don't understand what does mean p., pl., g., o...etc.. inside of queries? Now I have 2 sql queries

SELECT ps_attribute_lang.name
FROM ps_attribute_lang
LEFT JOIN ps_product_attribute_combination
ON ps_product_attribute_combination.id_attribute = ps_attribute_lang.id_attribute
WHERE ps_product_attribute_combination.id_product_attribute = "2061" 
AND ps_attribute_lang.id_lang="1"

and

SELECT d.id_order, d.product_reference, d.product_attribute_id, 
d.product_quantity,  g.firstname, g.lastname,  ai.address1, ai.address2,  
ai.postcode, ai.city, ai.other,  ai.phone_mobile
FROM ps_order_detail d
LEFT JOIN ps_orders o ON ( d.id_order = o.id_order ) 
LEFT JOIN ps_customer g ON ( o.id_customer = g.id_customer ) 
LEFT JOIN ps_stock_available s ON (d.product_id = s.id_product)
LEFT JOIN ps_address ad ON (o.id_address_delivery = ad.id_address)
LEFT JOIN ps_address ai ON (o.id_address_invoice = ai.id_address)
LEFT JOIN ps_group_lang gl ON ( g.id_default_group = gl.id_group ) 
LEFT JOIN ps_order_state_lang os ON ( o.current_state = os.id_order_state ) 
WHERE os.id_lang =1
GROUP BY d.id_order
ORDER BY d.id_order DESC

I want to combine these queries but don't know how. Please help

Link to comment
Share on other sites

The scope of the alias is limited to your SQL statement.  They are optional, and you can name them whatever you like

 

The following are all the same SQL statement

select * from ps_orders where id_order = 1
select * from ps_orders o where o.id_order = 1
select * from ps_orders orders where orders.id_order = 1
Link to comment
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
×
×
  • Create New...