Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

[SOLUCIONADO] sintaxis DELETE

Estas en el tema de sintaxis DELETE en el foro de Mysql en Foros del Web. Hola, en un "tutorial" de Oracle sobre MySQL me he encontrado esta orden: @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código MySQL: Ver original delete City , Country from Country ...
  #1 (permalink)  
Antiguo 27/01/2016, 11:20
 
Fecha de Ingreso: diciembre-2007
Mensajes: 299
Antigüedad: 16 años, 4 meses
Puntos: 2
sintaxis DELETE

Hola,
en un "tutorial" de Oracle sobre MySQL me he encontrado esta orden:

Código MySQL:
Ver original
  1. delete City,Country
  2. from Country inner join City
  3. on Country.Code=City.CountryCode
  4. where City.name=............

la sxis de DELETE es DELETE FROM tab1....; ¿porke en esta orden se indican las tablas a brorar(delete City,Country......)?
Gracias:D
__________________
1os pasaos con xAMP en Windows
programando en PERL
  #2 (permalink)  
Antiguo 27/01/2016, 11:30
Avatar de Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: sintaxis DELETE

Oracle sobre mysql?? o sea como?? oracle y mysql son 2 cosas distintas...lo que funciona en un DBMS puede no funcionar en otro
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me
  #3 (permalink)  
Antiguo 27/01/2016, 11:33
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 4 meses
Puntos: 2658
Respuesta: sintaxis DELETE

Cita:
en un "tutorial" de Oracle sobre MySQL me he encontrado esta orden:
Asumo que llegaste a l manual de MySQL desde la página de Oracle... ¿Es asi?

Como te dice Libras, no son la misma cosa. Oracle compró MySQL cuando adquirió a Sun Microsystems, pero no son el mismo DBMS. No confundas los términos.

Por otro lado, el manual es bastante detallado al respecto. ¿Lo leíste atentamente?
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #4 (permalink)  
Antiguo 27/01/2016, 12:14
 
Fecha de Ingreso: diciembre-2007
Mensajes: 299
Antigüedad: 16 años, 4 meses
Puntos: 2
Respuesta: sintaxis DELETE

Me explico..........es doumentacion sobre MySQL(probe la orden en MySQL y funciona perfectamente, aunque no se porque)
__________________
1os pasaos con xAMP en Windows
programando en PERL
  #5 (permalink)  
Antiguo 27/01/2016, 12:31
Avatar de gnzsoloyo
Moderador criollo
 
Fecha de Ingreso: noviembre-2007
Ubicación: Actualmente en Buenos Aires (el enemigo ancestral)
Mensajes: 23.324
Antigüedad: 16 años, 4 meses
Puntos: 2658
Respuesta: sintaxis DELETE

OK, pero ¿leíste o no leíste la documentación?

Cita:
Multi-Table Deletes

You can specify multiple tables in a DELETE statement to delete rows from one or more tables depending on the condition in the WHERE clause. You cannot use ORDER BY or LIMIT in a multiple-table DELETE. The table_references clause lists the tables involved in the join, as described in Section 13.2.9.2, “JOIN Syntax”.

For the first multiple-table syntax, only matching rows from the tables listed before the FROM clause are deleted. For the second multiple-table syntax, only matching rows from the tables listed in the FROM clause (before the USING clause) are deleted. The effect is that you can delete rows from many tables at the same time and have additional tables that are used only for searching:

Código MySQL:
Ver original
  1. DELETE t1, t2 FROM t1 INNER JOIN t2 INNER JOIN t3
  2. WHERE t1.id=t2.id AND t2.id=t3.id;
Or:
Código MySQL:
Ver original
  1. DELETE FROM t1, t2 USING t1 INNER JOIN t2 INNER JOIN t3
  2. WHERE t1.id=t2.id AND t2.id=t3.id;
These statements use all three tables when searching for rows to delete, but delete matching rows only from tables t1 and t2.

The preceding examples use INNER JOIN, but multiple-table DELETE statements can use other types of join permitted in SELECT statements, such as LEFT JOIN. For example, to delete rows that exist in t1 that have no match in t2, use a LEFT JOIN:
Código MySQL:
Ver original
  1. DELETE t1 FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL;
  2. The syntax permits .* after each tbl_name for compatibility with Access.
If you use a multiple-table DELETE statement involving InnoDB tables for which there are foreign key constraints, the MySQL optimizer might process tables in an order that differs from that of their parent/child relationship. In this case, the statement fails and rolls back. Instead, you should delete from a single table and rely on the ON DELETE capabilities that InnoDB provides to cause the other tables to be modified accordingly.
__________________
¿A quién le enseñan sus aciertos?, si yo aprendo de mis errores constantemente...
"El problema es la interfase silla-teclado." (Gillermo Luque)
  #6 (permalink)  
Antiguo 27/01/2016, 12:38
 
Fecha de Ingreso: diciembre-2007
Mensajes: 299
Antigüedad: 16 años, 4 meses
Puntos: 2
Respuesta: sintaxis DELETE

Parece ser k no estuve muy atento ese dia en clase

GRacias @gnzsoloyo :D
__________________
1os pasaos con xAMP en Windows
programando en PERL
  #7 (permalink)  
Antiguo 27/01/2016, 12:39
Avatar de Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: sintaxis DELETE

hace falta leer un poco mas las documentaciones ;)
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me

Etiquetas: delete, join, sintaxis, sql, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:25.