PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > where column
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
where column

Réponse
 
LinkBack Outils de la discussion
Vieux 24/08/2007, 06h07   #1
Olav Mørkrid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut where column

hello

does anyone know what is returned when you do a where column without
further parameters?

SELECT * FROM TABLE WHERE COLUMN;

for integer columns it seems to return non-zero columns, but for other
types of columns the results seemed unpredictable.
  Réponse avec citation
Vieux 24/08/2007, 06h16   #2
Reinhardt Christiansen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where column


----- Original Message -----
From: "Olav Mørkrid" <olav.morkrid@gmail.com>
To: <mysql@lists.mysql.com>
Sent: Friday, August 24, 2007 1:07 AM
Subject: where column


> hello
>
> does anyone know what is returned when you do a where column without
> further parameters?
>
> SELECT * FROM TABLE WHERE COLUMN;
>
> for integer columns it seems to return non-zero columns, but for other
> types of columns the results seemed unpredictable.
>

In my opinion, the statement should not execute at all since it isn't
syntactically correct. In the dialects of SQL I have used - and I've been
using SQL for a lot of years - simply saying "WHERE hiredate" (or whatever
column name you want) is an incomplete statement since the column name must
be followed by some kind of operator, such as =, <, >, LIKE, or whatever.

Despite that, I am not up-to-date on MySQL and they may support an extension
that lets you write SQL like that; in that case, the MySQL manual for your
version should make it clear what happens if you write that.

But I still think it should not execute at all. The WHERE clause is a filter
to prevent rows that don't satisfy the condition from appearing in your
result set; "WHERE columnname" is not a complete condition in my opinion so
it simply should execute.

--
Rhino

  Réponse avec citation
Vieux 27/08/2007, 20h15   #3
Shawn Green
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: where column

Olav Mørkrid wrote:
> hello
>
> does anyone know what is returned when you do a where column without
> further parameters?
>
> SELECT * FROM TABLE WHERE COLUMN;
>
> for integer columns it seems to return non-zero columns, but for other
> types of columns the results seemed unpredictable.
>
>

The value of the column will be converted to a TRUE or FALSE value (1 or
0). If the column would evaluate in a numerical setting to a value of 0,
the statement would read "WHERE FALSE" and not show that row. Can you
provide an example of a resultset that does not make sense to you?

Its no different than providing an actual equation to provide the true
or false condition

SELECT... FROM ... WHERE 0 will always return no data as the WHERE
condition will never be true.

--
Shawn Green, Support Engineer
MySQL Inc., USA, www.mysql.com
Office: Blountville, TN
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ /
/ /|_/ / // /\ \/ /_/ / /__
/_/ /_/\_, /___/\___\_\___/
<___/
Join the Quality Contribution Program Today!
http://dev.mysql.com/qualitycontribution.html

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 00h35.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09375 seconds with 11 queries