Jump to content

Wordpress SQL Issue


jarvis

Recommended Posts

Hi All,

 

Apologies is this is the wrong forum, I wasn't sure if it should be Wordpress or MySQL!

 

I hope someone can help! I've the following SQL which pulls info from Wordpress using the CIMY EXTRA Fields plugin. What I need to do is grab the last_name from the usermeta table too. However, I simply can't get it to work. Here's what I have:

			SELECT 
				$wpdb->users.ID,
				display_name,
				cimy_sector.VALUE as sector, 
				cimy_company.VALUE as company
			FROM 
				$wpdb->users, 
				{$wpdb->prefix}cimy_uef_data cimy_sector, 
				{$wpdb->prefix}cimy_uef_fields cimy_fields1,
				{$wpdb->prefix}cimy_uef_data cimy_company, 
				{$wpdb->prefix}cimy_uef_fields cimy_fields2
			WHERE $wpdb->users.ID = cimy_sector.USER_ID
			   AND $wpdb->users.ID = cimy_company.USER_ID
			   AND cimy_sector.FIELD_ID = cimy_fields1.ID
			   AND cimy_fields1.NAME ='SECTOR'
			   AND cimy_sector.VALUE = '".$companyType."'   
			   AND cimy_company.FIELD_ID = cimy_fields2.ID
			   AND cimy_fields2.NAME ='COMPANY'
			   AND cimy_company.VALUE LIKE '%".$search_by."%'"; 

Now this works fine and retrieves the correct data. I simply can't get another table and the result I need, any help is much appreciated!

 

TIA

Link to comment
Share on other sites

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.