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

    [SQL] Query errore su MySQL v5

    Ciao.
    Non riesco a capire cosa c'è che non va in
    questa query con la versione 5 di mysql
    (con la versione MySQL 4.1.8 funziona)

    la struttura del DB:

    Codice PHP:
    CREATE TABLE IF NOT EXISTS `categories` (
      `
    category_IDint(10unsigned NOT NULL auto_increment,
      `
    category_titlevarchar(100NOT NULL default '',
      `
    category_descriptiontext NOT NULL,
      
    PRIMARY KEY  (`category_ID`),
      
    UNIQUE KEY `category_title` (`category_title`)
    ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=;

    CREATE TABLE IF NOT EXISTS `posts` (
      `
    post_IDint(10unsigned NOT NULL auto_increment,
      `
    category_IDint(10unsigned NOT NULL default '0',
      `
    user_IDint(10unsigned NOT NULL default '0',
      `
    post_titletext NOT NULL,
      `
    post_preambletext NOT NULL,
      `
    post_contentlongtext NOT NULL,
      `
    post_datedatetime NOT NULL default '0000-00-00 00:00:00',
      
    PRIMARY KEY  (`post_ID`),
      
    KEY `category_ID` (`category_ID`),
      
    KEY `user_ID` (`user_ID`)
    ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=;

    CREATE TABLE IF NOT EXISTS `users` (
      `
    user_IDint(10unsigned NOT NULL auto_increment,
      `
    user_namevarchar(50NOT NULL default '''0''',
      
    PRIMARY KEY  (`user_ID`),
      
    KEY `user_name` (`user_name`)
    ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=

    e la query

    Codice PHP:
    SELECT c.category_titlep.category_IDp.post_ID,
    p.post_titlep.post_dateu.user_name FROM posts AS 
    INNER JOIN categories 
    AS c INNER JOIN users AS u ON 
    p
    .category_ID c.category_ID ON p.user_ID u.user_ID 
    ORDER BY p
    .post_ID DESC

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

  2. #2
    Matinataccia PP
    anche questa da errore

    Codice PHP:
    SELECT p.post_IDp.post_titlec.category_titleu.user_name
    FROM posts 
    AS p
    INNER JOIN categories 
    AS c
    INNER JOIN users 
    AS u ON p.category_ID c.category_ID ON p.user_ID u.user_ID
    WHERE p
    .post_ID = ( 
    SELECT MAXpost_ID 
    FROM posts 

    MySQL said:  
    #1054 - Unknown column 'p.category_ID' in 'on clause' 
    Without faith, nothing is possible. With it, nothing is impossible
    http://ilwebdifabio.it

  3. #3



    SELECT c.category_title, p.category_ID, p.post_ID, p.post_title, p.post_date, u.user_name
    FROM posts AS p
    INNER JOIN categories AS c ON p.category_ID = c.category_ID
    INNER JOIN users AS u ON p.user_ID = u.user_ID
    ORDER BY p.post_ID DESC
    LIMIT 0 , 30;
    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.