Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [SQL] JOIN che non restituisce risultato ...

    Ciao.
    Scusate il titolo un po bislacco

    Faccio una query del genere (questa
    è quella + facile nel senso che ha
    una where senza AND )

    Codice PHP:
    SELECT p.post_ID AS idp.post_title AS titlep.post_preamble AS preamble
            
    u.user_name AS authoru.user_ID AS uidc.category_ID AS cidc.category_title         AS ctitle,countco.post_ID ) AS ncomment 
            FROM posts 
    AS p INNER JOIN users AS u ON p.user_ID=u.user_ID
            INNER JOIN categories 
    AS c ON p.category_ID=c.category_ID
            LEFT JOIN comments 
    AS co ON p.post_ID =co.post_ID 
            WHERE co
    .comment_approved='1'
            
    GROUP BY p.post_ID DESC LIMIT 0 30
    Il problema è che se il post non ha nessun commento approvatonon mi restituisce niente come posso ovviare
    a sto inconveniente


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  2. #2
    UHm
    Così sembrerebbe funzionare
    Codice PHP:
    SELECT p.post_ID AS idp.post_title AS titlep.post_preamble AS preamble
            
    u.user_name AS authoru.user_ID AS uidc.category_ID AS cidc.category_title         AS ctitle,countco.post_ID ) AS ncomment 
            FROM posts 
    AS p INNER JOIN users AS u ON p.user_ID=u.user_ID
            INNER JOIN categories 
    AS c ON p.category_ID=c.category_ID
            LEFT JOIN 
    (SELECT post_ID FROM comments WHERE comment_approved='1'
            AS 
    co ON p.post_ID =co.post_ID 
            GROUP BY p
    .post_ID DESC LIMIT 0 30
    Se mi date il VS autorevole parere vi sarei enormemente
    grato


    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.