Skip to content
πŸš€ Rapid Application Development with the App Builder

Default Where ​

The default WHERE clause must be provided as valid SQL. It supports dynamic access to the WordPress user ID, URL parameters, and shortcode parameters.

The screenshot below shows the result for the URL: https://domain.com/page/?dname=sales

WP Data Access - Table Builder - Default WHERE

βš™οΈ Disable WHERE clause validation on INSERT ​

On INSERT, the data is validated against the default WHERE clause. If the clause is not satisfied, the INSERT fails. Enable this option to skip this validation.

πŸ“Œ Rows that do not satisfy the default WHERE clause will not be shown after INSERT.

✨ Example: AUTO INCREMENT column ​

An AUTO INCREMENT column does not have a value during an insert. The following default WHERE clause will fail validation on INSERT:

sql
id > 90000

To fix the validation error on INSERT:

  • Enable the "Disable WHERE clause validation on INSERT" option to skip validation on INSERT.
  • Or change the default WHERE clause to (id > 90000 OR id = '') to keep validation on INSERT.

Examples ​

✨ Example: Hardcoded Condition ​

sql
first_name like 'Sacha%'

✨ Example: Subquery ​

sql
user_id in
	(
		select user_id 
		from wp_usermeta 
		where meta_key = 'wp_capabilities'
		  and meta_value like '%coach%'
	)

✨ Example: Using SQL Functions ​

sql
order_date between date_sub(now(), interval 1 week) and now()

✨ Example: Combining Conditions ​

sql
where status = 'send'
  and order_date > date_sub(now(), interval 1 week)

Using HTTP GET and POST Parameters ​

Use the built-in variables httpGet, httpPost, and httpRequest to access parameters from a request. These functions return null if the specified parameter is not provided. (read more...)

✨ Example: Using a POST Parameter ​

sql
where product_id = httpPost['my_product_id']
  and httpPost['my_product_id'] is not null

✨ Example: Using a URL (GET) Parameter ​

sql
where product_id = httpGet['my_product_id'] 
  and httpGet['my_product_id'] is not null

✨ Example: Using the WordPres User ID ​

Use the session variable @wpda_wp_user_id to access the current WordPress user ID in your SQL. (read more…)

sql
user_id = @wpda_wp_user_id

Example: Using Shortcode Parameters ​

Shortcode wpda_app supports custom parameters, allowing users to add any parameter to a shortcode and safely reference its value in WHERE clauses. (read more...)

sql
WHERE status = IFNULL(shortcodeParam['status'], status)

πŸ“Œ Notes ​

  • The keyword WHERE is optional in this clause. For example, status = 'send' is functionally similar to where status = 'send'.