We can use the custom queries in wordpress. Using the custom queries we can fetch the wordpress table data as per our custom requirement.
how can we execute custom queries on wordpress
We you create your table then you can fetch values from that table using following command.
$ourdata = $wpdb->( "SELECT id, name FROM yourtable" );
If you want to create the table in wordpress then use following article.
https://purabtech.in/create-add-tables-wordpress-theme/
More example about executing the own custom quries.
$wpdb->query(" DELETE FROM $wpdb->postmeta WHERE post_id = '123' AND meta_key = 'google'");
another example about adding the data into table which is from wordpress:
$table_name = "your_table"; $welcome_name = "Mr. WordPressapi"; $welcome_text = "Congratulations, you just completed the installation!"; $insert = "INSERT INTO " . $table_name . " (time, name, text) " . "VALUES ('" . time() . "','" . $wpdb->escape($welcome_name) . "','" . $wpdb->escape($welcome_text) . "')"; $results = $wpdb->query( $insert );
Getting the single value from any table
$user_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->users;"));
Get the single row value from wordpress table
$mylink = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = 10", ARRAY_A);
you can use inner join, outer join and multiple join in wordpress custom queries.
I enjoyed reading your interesting yet very informative insights. I am looking forward to reading more of your most recent articles and blogs.