I need to exclude first id entry, and display the rest on my wordpress, I have never used sql before.
$all_users_id = $wpdb->get_col( $wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", $sort ));
I need to exclude first id entry, and display the rest on my wordpress, I have never used sql before.
$all_users_id = $wpdb->get_col( $wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC", $sort ));
I am not familiar with Wordpress, but try this:
$all_users_id = $wpdb->get_col( $wpdb->prepare("SELECT $wpdb->users.ID FROM $wpdb->users WHERE $wpdb->users.ID NOT IN (SELECT MIN($wpdb->users.ID) FROM $wpdb->users) ORDER BY %s ASC", $sort ));
One way would be to use something like
SELECT *
FROM Table
WHERE ID > (SELECT MIN(ID) FROM Table)
$all_users_id = $wpdb->get_col( $wpdb->prepare("SELECT `$wpdb->users.ID` FROM `$wpdb->users` WHERE `$wpdb->users.ID` != 1 ORDER BY %s ASC", $sort ));
The query used:
SELECT `$wpdb->users.ID`
FROM `$wpdb->users`
WHERE `$wpdb->users.ID` != 1
ORDER BY %s ASC
Fast and simple... Without sub-querys! :)
If it's a mysql db then use the limit clause:
SELECT `$wpdb->users.ID`
FROM `$wpdb->users`
ORDER by $sort ASC
LIMIT 1,9999999
C.