Re: Ambiguous?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 09/08/2013 14:00, Karl-Arne Gjersøyen wrote:
1) query
foreach($varenr_inn_pa_lager as $vnr){
             include('../../tilkobling.php');
             $sql = "SELECT * FROM exan,dynamit WHERE varenr = '$vnr' LIMIT
1";
             $resultat = mysql_query($sql, $tilkobling) or
die(mysql_error());

2) Result:
Column 'varenr' in where clause is ambiguous

3) Tables in MySQL database

mysql> SELECT * FROM exan;
+------------+-------------+-------+----------+----------+-------------+
| leverandor | valgt_lager | un_nr | varenavn | varenr   | kg_pa_lager |
+------------+-------------+-------+----------+----------+-------------+

mysql> SELECT * FROM dynamit;
+------------+-------------+---------------+--------+-------+---------------------+------------+-------------+
| leverandor | valgt_lager | type          | dim_mm | un_nr |
varenavn            | varenr     | kg_pa_lager |
+------------+-------------+---------------+--------+-------+---------------------+------------+-------------+

4) My question:
What means with "ambiguous" here?

Thanks.
Karl
a field named 'varenr' exists in both tables - your sql query needs to specify from which table you are selecting the data.

foreach($varenr_inn_pa_lager as $vnr){
           include('../../tilkobling.php');
           $sql = "SELECT * FROM exan,dynamit WHERE varenr = '$vnr' LIMIT


do you really need to include the file 'tilkobling.php' repeatedly for each iteration over $varenr_inn_pa_lager??

Rich


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux