sql >> Database teknologi >  >> RDS >> Mysql

Få indlæg fra alle kategorier undtagen én kategori

Prøv nedenfor :-

14 er kategori-id

 $request = $wpdb->prepare("SELECT * FROM $wpdb->posts 
  LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)  
  LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)  

  WHERE ($wpdb->term_taxonomy.term_id <> 14  
     AND $wpdb->term_taxonomy.taxonomy = 'category'   
     AND $wpdb->posts.post_type = 'post'  
     AND $wpdb->posts.post_status = 'publish'
     AND post_title like '%$search%'
     AND post_date >= '" . date('Y-m-d').")");



  1. SQL Server SHOWPLAN_ALL

  2. Sådan laver du innodb som standardmotor

  3. MySQL / PHP transaktionsadfærd

  4. Vis alle nullbare kolonner i en SQL Server-database