Results 1 to 2 of 2

Thread: Help for Query

  1. #1
    Join Date
    Aug 2003

    Question Unanswered: Help for Query


    I have the follwoing two tables and I want to select all data from rps_spielplan where no entry for a specific user_id in rps_tippspiel exists.
    Can someone help me?

    CREATE TABLE rps_spielplan (
    spiel_id mediumint(6) NOT NULL auto_increment,
    datum int(14) unsigned NOT NULL default '0',
    heim mediumint(6) NOT NULL default '0',
    gast mediumint(6) NOT NULL default '0',
    tore_heim mediumint(6) NOT NULL default '0',
    tore_gast mediumint(6) NOT NULL default '0',
    halle int(14) default NULL,
    spieltag smallint(2) NOT NULL default '0',
    PRIMARY KEY (spiel_id),
    UNIQUE KEY spiel_id (spiel_id)
    ) TYPE=MyISAM;

    CREATE TABLE rps_tippspiel (
    spiel_id mediumint(6) default NULL,
    user_id mediumint(6) default NULL,
    tore_heim mediumint(6) default NULL,
    tore_gast mediumint(6) default NULL,
    datum int(14) default NULL,
    punkte tinyint(1) default NULL,
    ausgewertet tinyint(1) default NULL
    ) TYPE=MyISAM;

    The syntax for ORACLE would be:
    Select * from rps_spielplan where spiel_id NOT IN (Select spiel_id from rps_tippspiel where user_id = <VALUE>
    Last edited by Langer; 08-13-03 at 06:18.

  2. #2
    Join Date
    Jul 2003

    If you are using MySQL 4.1, your existing subselect statement should work ok.

    For MySQL <4.1, you could try...

    select * FROM rps_spielplan AS r LEFT JOIN rps_tippspiel AS t ON r.spiel_id=t.spiel_id where r.spiel_id !=<VALUE> GROUP BY r.spiel_id;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts