ouf newbe Column: 'nom' in field list is ambiguous

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default ouf newbe Column: 'nom' in field list is ambiguous

    Hi,

    The column nom is declare in all thee tables as INDEX

    The idea as you gest is to print everything from all tables related to a
    name. (nom translate name)


    mysql_select_db("pierredata");

    $res = mysql_query('SELECT nom, commentaire FROM cours,
    peinture_plein_air, commentaires WHERE cours.nom = peinture_plein_air.nom
    and peinture_plein_air.nom = commentaires.nom;');

    if (!$res) {
    echo "<p>"."Impossible ($res) in base : " . mysql_error();
    exit();
    }

    if (mysql_num_rows($res) == 0) {
    echo "<p>"."Nothing found.";
    exit();
    }

    Jean


    Québec Guest

  2. Similar Questions and Discussions

    1. Converting a 3 column pdf address list to a one column MS word doc
      I need to convert a 3 col pdf into a manipulable text doc. Acrobat gives me lots of ways to do this in the normal program, but it doesn't preserve...
    2. Searching a column containing a list against a form list
      I have a form that allows users to select multiple items from a list. form.hobbies = 1,5,3,6,8,2 (from a table pullup) I want to be able to...
    3. ambiguous match found
      see code & error below. i noticed that the page parser only calles the set property so i decided to program it like below so that the set...
    4. Multi Column List Box
      Neils, Thank you for your suggestion. The method you mention is completely new to me. I have only recently switched from Paradox to Access. In...
    5. Ambiguous between two types of query
      Hello I'm ambiguous between two types of query. :) I want to show you two differen written query. Both of them do same job and both of them I...
  3. #2

    Default Re: ouf newbe Column: 'nom' in field list is ambiguous

    Québec wrote:
    > $res = mysql_query('SELECT nom, commentaire FROM cours,
    > peinture_plein_air, commentaires WHERE cours.nom =
    > peinture_plein_air.nom and peinture_plein_air.nom =
    > commentaires.nom;');
    >
    You need to apply the AS clause to create aliasses, example:

    SELECT crs.nom, ppa.nom, com.nom FROM cours AS crs,
    peinture_plein_air AS ppa, commentaires AS com WHERE crs.nom =
    ppa.nom and ppa.nom = com.nom;

    Also, have a look at INNER JOINS:

    [url]http://dev.mysql.com/doc/mysql/en/JOIN.html[/url]


    JW



    Janwillem Borleffs Guest

  4. #3

    Default Re: ouf newbe Column: 'nom' in field list is ambiguous


    "Québec" <Once@WasEno.ugh> wrote in message
    news:EgJ0d.85206$FX3.1205899@weber.videotron.net.. .
    > Hi,
    >
    > The column nom is declare in all thee tables as INDEX
    >
    > The idea as you gest is to print everything from all tables related to a
    > name. (nom translate name)
    >
    >
    > mysql_select_db("pierredata");
    >
    > $res = mysql_query('SELECT nom, commentaire FROM cours,
    > peinture_plein_air, commentaires WHERE cours.nom = peinture_plein_air.nom
    > and peinture_plein_air.nom = commentaires.nom;');
    >
    > if (!$res) {
    > echo "<p>"."Impossible ($res) in base : " . mysql_error();
    > exit();
    > }
    >
    > if (mysql_num_rows($res) == 0) {
    > echo "<p>"."Nothing found.";
    > exit();
    > }
    >
    > Jean
    >
    >
    You need to specify which table "nom" is to come from in your SELECT

    e.g. SELECT cours.nom



    Andy Guest

  5. #4

    Default Re: ouf newbe Column: 'nom' in field list is ambiguous

    Ok
    Now I have

    $res = mysql_query('SELECT etudiants.nom, commentaires.nom FROM
    etudiants, commentaires WHERE etudiants.nom = commentaires.nom;');

    while($row=mysql_fetch_array($res)){
    $line++;
    print $line.'<br>';
    }

    It prints 1 ??????????????????


    --------------------------------------
    In the tables:
    nom refers to Jean Pierre Daviau
    ====== comentaire========== first column
    ('Jean Pierre Daviau', 'dddd@videotron.ca', 'Bonjour', 'Bonjour',
    '2004-09-11');
    ====== etudiant==========third column
    ('dddd@videotron.ca', 'c#nC01rfgN', 'Jean Pierre Daviau', 'moi', 'gggg',
    '5145555522', '2004-09-09');
    ================

    CREATE TABLE `etudiants` (
    `courriel` char(40) NOT NULL default '',
    `passe` char(15) NOT NULL default '',
    `nom` char(60) NOT NULL default '',
    `image` char(20) NOT NULL default '',
    `adresse` char(80) NOT NULL default '',
    `tel` char(11) NOT NULL default '',
    `date` date NOT NULL default '0000-00-00'
    ) TYPE=MyISAM PACK_KEYS=1;

    CREATE TABLE `commentaires` (
    `nom` varchar(50) NOT NULL default '',
    `courriel` varchar(50) NOT NULL default '',
    `sujet` varchar(50) NOT NULL default '',
    `commentaire` text NOT NULL,
    `date` date NOT NULL default '0000-00-00',
    KEY `nom` (`nom`)
    ) TYPE=MyISAM;
    Jean Pierre


    Québec Guest

  6. #5

    Default Re: ouf newbe Column: 'nom' in field list is ambiguous


    "Québec" <Once@WasEno.ugh> wrote in message
    news:hp%0d.13564$Qa2.185145@weber.videotron.net...
    > Ok
    > Now I have
    >
    > $res = mysql_query('SELECT etudiants.nom, commentaires.nom FROM
    > etudiants, commentaires WHERE etudiants.nom = commentaires.nom;');
    >
    > while($row=mysql_fetch_array($res)){
    > $line++;
    > print $line.'<br>';
    > }
    >
    > It prints 1 ??????????????????
    >
    >
    > --------------------------------------
    > In the tables:
    > nom refers to Jean Pierre Daviau
    > ====== comentaire========== first column
    > ('Jean Pierre Daviau', 'dddd@videotron.ca', 'Bonjour', 'Bonjour',
    > '2004-09-11');
    > ====== etudiant==========third column
    > ('dddd@videotron.ca', 'c#nC01rfgN', 'Jean Pierre Daviau', 'moi', 'gggg',
    > '5145555522', '2004-09-09');
    > ================
    >
    > CREATE TABLE `etudiants` (
    > `courriel` char(40) NOT NULL default '',
    > `passe` char(15) NOT NULL default '',
    > `nom` char(60) NOT NULL default '',
    > `image` char(20) NOT NULL default '',
    > `adresse` char(80) NOT NULL default '',
    > `tel` char(11) NOT NULL default '',
    > `date` date NOT NULL default '0000-00-00'
    > ) TYPE=MyISAM PACK_KEYS=1;
    >
    > CREATE TABLE `commentaires` (
    > `nom` varchar(50) NOT NULL default '',
    > `courriel` varchar(50) NOT NULL default '',
    > `sujet` varchar(50) NOT NULL default '',
    > `commentaire` text NOT NULL,
    > `date` date NOT NULL default '0000-00-00',
    > KEY `nom` (`nom`)
    > ) TYPE=MyISAM;
    > Jean Pierre
    >
    >

    Well that's correct isn't it ? You're printing out a counter (line) which
    you increment for each match of "nom" betweem the tables etudiants
    and commentaires. From the name sample you show above then there
    is one match so "line" gets set to 1.


    Andy Guest

  7. #6

    Default Re: ouf newbe Column: 'nom' in field list is ambiguous

    Thank you very much that works!
    Jean
    ===============
    $result = mysql_query('SELECT etudiants.nom, etudiants.courriel,
    etudiants.passe, commentaires.nom, commentaires.sujet,
    commentaires.commentaire FROM etudiants, commentaires WHERE etudiants.nom
    = commentaires.nom;');
    $line=0;
    if (!$result) {
    echo "<p>"."Impossible d'exécuter la requête ($result) dans la base
    : " . mysql_error();
    exit();
    }

    if (mysql_num_rows($result) == 0) {
    echo "<p>"."Aucune ligne trouvées, rien à afficher.";
    exit();
    }
    $num_results = mysql_num_rows($result);
    echo "<p>Number of passe found: ".$num_results."</p>";

    for ($i=0; $i <$num_results; $i++)
    {
    $row = mysql_fetch_array($result);
    echo "<p><strong>".($i+1).". nom: ";
    echo stripslashes($row["nom"]);
    echo "</strong><br>courriel: ";
    echo stripslashes($row["courriel"]);
    echo "<br>passe: ";
    echo stripslashes($row["passe"]);
    echo "<br>sujet: ";
    echo stripslashes($row["sujet"]);
    echo "<br>commentaire: ";
    echo stripslashes($row["commentaire"]);
    echo "</p>";


    Québec Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139