You need 2 table joins since there are effectively 2 meta keys in your WHERE clause:
SELECT DISTINCT
SQL_CALC_FOUND_ROWS wp_users.*
FROM
wp_users
INNER JOIN wp_usermeta AS um1 ON (wp_users.ID = um1.user_id)
INNER JOIN wp_usermeta AS um2 ON (wp_users.ID = um2.user_id)
WHERE
(wp_users.user_login LIKE '%little%'
OR wp_users.user_email LIKE '%little%'
OR wp_users.user_url LIKE '%little%'
OR wp_users.display_name LIKE '%little%'
OR (um1.meta_key = 'first_name'
AND um1.meta_value LIKE '%little%')
OR (um1.meta_key = 'last_name'
AND um1.meta_value LIKE '%little%'))
AND((um2.meta_key = 'car_type'
AND um2.meta_value LIKE '%Camry%')
OR(um2.meta_key = 'car_type'
AND um2.meta_value LIKE '%Toyota%'))
ORDER BY
user_registered DESC
Related Posts:
- Getting wrong relationship value in $args in wp_Query?
- How is the data stored in the database?
- Activation hook not creating table
- Is the usage of ON DELETE CASCADE wrong or not allowed on wordpress?
- Version upgrade: can my plugin filter the SQL statements issued during a database upgrade?
- WordPress database error for query INSERT INTO
- How to connect to AWS RDS external database (not for the core WordPress db)
- Alternative functions for mysql_free_result and mysql_ping in wordpress functions
- Two different wordpress sites – same server and IP address. Gaining Access to database 1 of 2
- What might be the reason of Couldn’t fetch mysqli_result on another domain?
- WordPress database error: [Query was empty] – using $wpdb->prepare()
- WordPress how do I echo SUM from a column of a MySQL table by user id AND type_operation
- WordPress doesn’t create table on plugin activation
- Organising and completing posts (mark as read and hide)
- pull data from wordpress database
- How to filter get_adjacent_post()?
- Is it necessary to do validation again when retrieving data from database?
- How to get all queries’s results after they have executed?
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- What is the best way to store a few fields?
- Plugin: database creation
- Adding columns to core tables
- How to query custom db table?
- Delete data from database using row action
- Show dynamic list of products from custom api of another database under same host
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- $wpdb->prepare with LIKE and sprintf
- Why this query is not showing any result on wordpresss home page?
- How to optimize multiple insert into wordpress database
- wpdb prepare insert table doesn’t work
- Make Database query only when option is updated
- Can we intercept user_login and user_pass from a wp_login_form?
- How best to handle database version dependence (from $wp_db_version)
- WP: Search and replace in DB programmatically
- Why does changing Database Table Prefixes result in loss of content?
- DB Query not working in Plugin
- SQL query to set posts in bulk based on the post content
- WP MultiSite: Can’t select database error after changing to new domain
- How can I programmatically change a MySql variable (foreign_keys_check)?
- Auto-complete or auto-suggest from stored data in database
- Plugin Development: Storing and Manipulating Data That Fits JSON in Database
- wpdb->get_var always returning 0
- $wpdb->prepare is not working like mysql_real_escape_string
- WordPress plugin: efficient way to store large data
- Brainstorm – Slow Query from Plugin Need to Speed It Up
- How do I debug an error that a plugin is causing?
- $wpdb->get_var – What value is returned when zero records are found?
- Save temporary registration data
- Create an user on external database
- Update plugin settings option_name for big plugin update
- What could cause a WP Option to get truncated?
- select a single val though a table in wordpress
- $wpdb->update Issue
- Integrating Custom Database with WordPress
- How to display results from a data table with an encrypted user id?
- dbdelta failing with error: “WordPress database error Table ‘wp_2_myPlugin’ already exists
- Foreign wp_users ID in custom plugin DB table?
- How to Get Last ID?
- Error code when migrate
- DB prefix not updating
- Performing CRUD operations on front end in wordpress
- Why User_login key doesn’t work with wp_update_user()
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- How to store sensitive user data (passwords)
- Insert, update or remove data from database (usermeta)
- How to get inserted row IDs for bulk/batch insert with wpdb query?
- Why is that only the first row getting inserted into Mysql table when i import csv file on backend custom plugin?
- Bulk find & replace on WordPress posts/pages (minus image paths)
- Error Connecting to Database WHEN Installing WordPress on XAMPP [Tried All the Usual Stuff] (Pics Included)
- WordPress Fatal error: Uncaught Error: Call to undefined function dbDelta()
- Is it possible to replace MySQL with JSON files for WordPress
- Use admin-post to submit form data to external database
- How to create index (sql) to a meta_key?
- Save in my custom admin page and redirect to the saved object
- Relational / Associate tables using native WordPress functionality
- The function is deprecated; use mysql_real_escape_string() instead
- Delete all users meta that named: user_avatar
- Insert Data into Database
- Update database record in plugin
- WordPress delete mysql rows with string
- How to store in the database directly the translation?
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- How and when would I implement some code which would take data from one part of the Db and put it in another?
- Plugin MySQL SELECT custom data and filter on user meta
- sql query not working in wp plugin
- $wpdb Mysql trigger problem
- can’t delete a row from post_meta table
- Ajax not working to insert, query and result data
- Custom MySQL query to pull out Advanced Custom Fields?
- I can’t write in my DB using $wpdb->insert
- Why Worpdress doesn’t create table in database?
- Form and database, plugin development
- Associating special meaning with user id 0
- $wpdb how can i save my postmeta table before querying it
- How to add chunk of php, html, and sql code to variable an append to $content
- What method should I use to store my plugin data (multi level menus with options on each item)
- How to add additional field in a table row after creating a table?
- WordPress plugin tables become corrupt
- Post data in wp-admin to external database
- Nothing happens on WordPress Update command