Jump to content
xisto Community
imjjss

What Does Pd Pa Mean In Sql Query?

Recommended Posts

I have no knowledge about sql but I need to run a query. I found an example which get exactly output formate that I want. I plan to borrow this query script but it's very difficult to understand the code, especially, the pd, pa part, What does pd, pa mean in this code?

$query = <<<QUERY			SELECT 	DISTINCT(u.ID),				u.user_email,				u.user_nicename,				u.display_name,				pd.value				FROM $wpdb->users u 			LEFT				JOIN {$bp->profile->table_name_data} pd 				ON u.ID = pd.user_id			LEFT 				JOIN (					SELECT DISTINCT( p.post_author ) ID					FROM $wpdb->posts p					WHERE						p.post_type = 'ep_reg'						AND p.post_parent = $postid						$for_admin				) pa				ON u.ID = pa.ID			WHERE 				u.user_status = 0				AND pa.ID IS NULL				AND pd.field_id = 1			ORDER BY pd.value ASCQUERY;

Share this post


Link to post
Share on other sites

What does pd, pa mean in this code?

pa and pd are short names for tables, for that nice query.
ON u.ID = pd.user_id
pd.user means the colum "user" of the "pd" table.
AND pa.ID IS NULL
"pa.id IS NULL" means there is no value in the field "ID" for this row of the table "pa".

I have no knowledge about sql

From a history point of view, "SQL" means "Simple Query Language".This was supposed to be a very simple language for querying data, a language supposed to be simple because it's near the natural (English) language.
For instance, selecting the names of the employees being overpaid should sound like "select * from employees where salary greater than 2000;"

Share this post


Link to post
Share on other sites

yes tables... and @ yordan, yes it isn't simple from a newbies perspective! although when i started learning SQL it seem quite simple (the basics) at first which can be quite straight forward until you get to do more complex queries... i suggest googling for some free introductory e-books on SQL or even online Tutorials... should give you some brief idea about SQL... good place to start is w3schools http://www.w3schools.com/sql/default.asp

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

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.