Mostrando entradas con la etiqueta sql. Mostrar todas las entradas
Mostrando entradas con la etiqueta sql. Mostrar todas las entradas

domingo, 28 de agosto de 2011

Use '=' or LIKE to compare strings in SQL?


LIKE and the equality operator have different purposes, they don't do the same thing: = is much faster, whereas LIKE can interpret wildcards. Use = wherever you can and LIKE wherever you must.

SELECT * FROM user WHERE login LIKE 'Test%';
-- Matches
-- TestUser1
-- TestUser2
-- TestU
-- Test
-- etc.

Registros duplicados con SQL

Here's a handy query for finding duplicates in a table. Suppose you want to find all email addresses in a table that exist more than once:

SELECT email,
COUNT(email) AS NumOccurrences
FROM users
GROUP BY email
HAVING ( COUNT(email) > 1 )

You could also use this technique to find rows that occur exactly once:
SELECT email
FROM users
GROUP BY email
HAVING ( COUNT(email) = 1 )

Limpiar un Wordpress hackeado

 Check list para limpiar instancias de Wordpress que han sido hackeadas, y para prevenir hackeos. Para técnicos de sistemas con acceso SSH a...