PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > What are these queries used for?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
What are these queries used for?

Réponse
 
LinkBack Outils de la discussion
Vieux 16/10/2007, 18h50   #1
Mukesh_Singh_Nick@yahoo.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut What are these queries used for?

I've come accross queries like this one previously but never got the
time to carefully study them form some book.

SELECT 1 WHERE 1 = 1

1) What do queries like these mean? From common sense, I can deduce
that it is some kind of a test for a boolean value, but the result is
already deterministic in the above case (true).

What use is such a query for?

2) I tried the query on mySQL 4.1 and it doesn't work. Raises a syntax
error. Are they specific to some dialect of SQL?

3) What dialect (T-SQL/ANSI SQL/PL/SQL) of SQL does mySQL use?

  Réponse avec citation
Vieux 16/10/2007, 19h19   #2
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What are these queries used for?

Mukesh_Singh_Nick@yahoo.com wrote:
> I've come accross queries like this one previously but never got the
> time to carefully study them form some book.
>
> SELECT 1 WHERE 1 = 1


This ain't really working in mysql, but "SELECT 1" does and it's the same.


> 1) What do queries like these mean? From common sense, I can deduce
> that it is some kind of a test for a boolean value, but the result is
> already deterministic in the above case (true).


Yes, 1=1 is always true and selecting 1 will then always been done.


> What use is such a query for?


It's more suited to test if the database connection is still working.



> 2) I tried the query on mySQL 4.1 and it doesn't work. Raises a syntax
> error. Are they specific to some dialect of SQL?


There are always some tricks in each database and sometimes it may not be that
useful.


> 3) What dialect (T-SQL/ANSI SQL/PL/SQL) of SQL does mySQL use?


MySQL


--

//Aho
  Réponse avec citation
Vieux 16/10/2007, 20h34   #3
lark
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: What are these queries used for?

== Quote from Mukesh_Singh_Nick ( Mukesh_Singh_Nick@yahoo.com)'s article
> I've come accross queries like this one previously but never got the
> time to carefully study them form some book.
> SELECT 1 WHERE 1 = 1
> 1) What do queries like these mean? From common sense, I can deduce
> that it is some kind of a test for a boolean value, but the result is
> already deterministic in the above case (true).
> What use is such a query for?
> 2) I tried the query on mySQL 4.1 and it doesn't work. Raises a syntax
> error. Are they specific to some dialect of SQL?
> 3) What dialect (T-SQL/ANSI SQL/PL/SQL) of SQL does mySQL use?


to answer your last question, MySQL uses ANSI SQL, any scripts written in ansi
will work in MySQL. there are some extra commands within MySQL that are unique to
it though.

--
POST BY: lark with PHP News Reader
  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 01h08.


É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,10151 seconds with 11 queries