Esta es la lista de paises
SELECT * FROM countries
Name |
Capital |
Continent |
Mexico |
DF |
America |
USA |
Washington |
America |
Spain |
Madrid |
Europe |
France |
Paris |
Europe |
Egypt |
Cairo |
Africa |
Portugal |
Lisboa |
Europe |
Portigal |
Lisboa |
Europe |
Portagal |
Lisboa |
Europe |
Eslovenia |
Liubliana |
Europe |
Eslovenia |
Liubliana |
Europe |
Letonia |
Riga |
Europe |
Italia |
Roma |
Europe |
Thailand |
Bangkok |
Asia |
Indonesia |
Yakarta |
Asia |
Cómo mostrar todos los duplicados:
SELECT a.* FROM countries a JOIN (SELECT name, capital, COUNT(*) FROM countries GROUP BY name, capital HAVING COUNT(*) > 1) b ON a.name = b.name;
Name |
Capital |
Continent |
Eslovenia |
Liubliana |
Europe |
Eslovenia |
Liubliana |
Europe |
Cómo mostrar todos los resultados con Capital = Lisboa, Continente = Europe y que el nombre empiece por P:
Resultados: 3
SQL
SELECT * FROM countries WHERE Capital = "Lisboa" AND continent = "Europe" AND name LIKE "P%"
PHP
echo 'Resultados: '.mysqli_num_rows(mysqli_query($db,$newquery));