3
I would like to make sure that after running the script, there can only be the last 12 records in a specific table that has the date field in international format if it can assist.
<?php
# Este pequeno script PHP recupera o OD do imóvel visitado
# e o cadastra no banco de dados permitindo assim que o
# módulo de ULTIMOS IMOVEIS VISUALIZADOS esteja sempre
# atualizado.
# Variaveis
$cod_imovel = $_GET['cod_consulta'];
$data = date('Y-m-d H:i:s');
$visitado = 1;
#SQL Execute
$sql = "INSERT INTO visitados (cod_imovel, visitado, data) VALUES (:cod_imovel, :visitado, :data)";
$query = $pdo->prepare($sql);
$query->execute(array(':cod_imovel' => $cod_imovel, ':visitado' => $visitado, ':data' => $data));
#Apagar todos os registros menos os 12 últimos
?>
It seems that the server does not accept subquerys... another way?
What is the primary key of this table (if it has a)?
– Caffé
IS id even.
– Marcos Vinicius
What version of mysql?
– gmsantos
The Mysql version is 5.1.46
– Marcos Vinicius
I edited my answer with
JOIN
as an option to suquery not supported by your Mysql version.– Caffé