Quote from CDY@44 on September 29, 2019, 12:39 amHello,
I would like to know how to make a search of a specific data in a online database table. SQL ?
Best regards,
Denis
Hello,
I would like to know how to make a search of a specific data in a online database table. SQL ?
Best regards,
Denis
Quote from luishp on October 1, 2019, 9:48 am@cdy44-2 do you mean something like this?
SQL:SELECT * FROM mytable WHERE mycolumn = "dataToSearch"In VisualNEO Web would be something like this in config.php:
$sqlAlias[0]="myquery1"; $sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn=?"; $sqlMaxUserLevel[0]=-1;And then within your project:
neoPhpExecSql "mydatabase" "myquery1" "dataToSearch" "mysubroutine"I hope it helps.
@cdy44-2 do you mean something like this?
SQL:
SELECT * FROM mytable WHERE mycolumn = "dataToSearch"
In VisualNEO Web would be something like this in config.php:
$sqlAlias[0]="myquery1"; $sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn=?"; $sqlMaxUserLevel[0]=-1;
And then within your project:
neoPhpExecSql "mydatabase" "myquery1" "dataToSearch" "mysubroutine"
I hope it helps.
Quote from Palamar on March 6, 2020, 1:24 pmHola Luis!:
He tomado esto:
SELECT * FROM mytable WHERE mycolumn = "dataToSearch"pero quiero hacer esto:
SELECT * FROM mytable WHERE mycolumn = "%dataToSearch%"Cuando en el config.php coloco los % y en medio el ? pues no funciona. He intentado con comillas simples, dobles y sin comillas sin resultados, existe un reemplazo para "%" en VisualNeo?.
Saludos!
Hola Luis!:
He tomado esto:
SELECT * FROM mytable WHERE mycolumn = "dataToSearch"
pero quiero hacer esto:
SELECT * FROM mytable WHERE mycolumn = "%dataToSearch%"
Cuando en el config.php coloco los % y en medio el ? pues no funciona. He intentado con comillas simples, dobles y sin comillas sin resultados, existe un reemplazo para "%" en VisualNeo?.
Saludos!
Quote from luishp on March 6, 2020, 1:44 pmHola @palamar,
Fíjate que en este caso estás trabajando con PHP. Quiero decir que las soluciones no son específicas de VisualNEO Web ni de neoPHP. De acuerdo a esto, seguramente funcionará así:
SELECT * FROM mytable WHERE mycolumn LIKE "%".?."%"El punto permite concatenar cadenas en PHP.
Ten cuidado de no poner comillas dobles dentro de otras comillas dobles, utiliza comillas sencillas en su lugar.
Hola @palamar,
Fíjate que en este caso estás trabajando con PHP. Quiero decir que las soluciones no son específicas de VisualNEO Web ni de neoPHP. De acuerdo a esto, seguramente funcionará así:
SELECT * FROM mytable WHERE mycolumn LIKE "%".?."%"
El punto permite concatenar cadenas en PHP.
Ten cuidado de no poner comillas dobles dentro de otras comillas dobles, utiliza comillas sencillas en su lugar.
Quote from Palamar on March 6, 2020, 1:49 pm@luishp, sí, llevas razón en los puntos, lo obvie por completo, me pasan esas lagunas jajaj, lo pruebo. Mil gracias!.
@luishp, sí, llevas razón en los puntos, lo obvie por completo, me pasan esas lagunas jajaj, lo pruebo. Mil gracias!.
Quote from Palamar on March 6, 2020, 2:21 pm@luishp pues no ha funcionado, es extraño, si solo pongo el ? busca con el match exacto por lo que la consulta la hace. Así lo he probado (no me ha dejado subir la sintaxis, me ha bloqueado el servidor del foro, no es la primera vez)
@luishp pues no ha funcionado, es extraño, si solo pongo el ? busca con el match exacto por lo que la consulta la hace. Así lo he probado (no me ha dejado subir la sintaxis, me ha bloqueado el servidor del foro, no es la primera vez)
Quote from Gaev on March 6, 2020, 3:26 pm@palamar
According to this page ... https://www.w3schools.com/sql/sql_wildcards.asp ... it looks like you need to use the LIKE operator (NOT the = sign) when searching with wildcards ... perhaps you can try the syntax below ... just replace {percent-sign-here} with % (because Forum software objects when I try to use actual % signs) ...
SELECT * FROM mytable WHERE mycolumn LIKE "{percent-sign-here}dataToSearch{percent-sign-here}"
According to this page ... https://www.w3schools.com/sql/sql_wildcards.asp ... it looks like you need to use the LIKE operator (NOT the = sign) when searching with wildcards ... perhaps you can try the syntax below ... just replace {percent-sign-here} with % (because Forum software objects when I try to use actual % signs) ...
SELECT * FROM mytable WHERE mycolumn LIKE "{percent-sign-here}dataToSearch{percent-sign-here}"
Quote from Gaev on March 6, 2020, 7:21 pm@palamar
I tried that, but it doesn't work. Yes it looks for exact if I remove the%
1) can you post what database (mySQL, Oracle etc.) that you are using ? (e.g. Microsoft Access uses different wildcard characters than mySQL)
2) in order to pinpoint the root cause, perhaps you can try these one at a time ...
Assuming your client side command is ...
neoPhpExecSql "yourDatabase" "yourAlias" "[varForDataToSearch]" "subroutineToHandleResponse"a) no wildcards; exact match (I believe you have confirmed that this works)
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '?'";b) begins with dataToSearch and has 0 to many additional characters
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '?%'";c) begins with 0 to many characters but ends with dataToSearch
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '%?'";d) has any 1 character followed by dataToSearch
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '_?'";e) begins with dataToSearch plus any 1 character
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '?_'";Post your results here.
I tried that, but it doesn't work. Yes it looks for exact if I remove the%
1) can you post what database (mySQL, Oracle etc.) that you are using ? (e.g. Microsoft Access uses different wildcard characters than mySQL)
2) in order to pinpoint the root cause, perhaps you can try these one at a time ...
Assuming your client side command is ...
neoPhpExecSql "yourDatabase" "yourAlias" "[varForDataToSearch]" "subroutineToHandleResponse"
a) no wildcards; exact match (I believe you have confirmed that this works)
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '?'";
b) begins with dataToSearch and has 0 to many additional characters
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '?%'";
c) begins with 0 to many characters but ends with dataToSearch
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '%?'";
d) has any 1 character followed by dataToSearch
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '_?'";
e) begins with dataToSearch plus any 1 character
$sqlQuerys[0]="SELECT * FROM mytable WHERE mycolumn LIKE '?_'";
Post your results here.
Quote from luishp on March 6, 2020, 8:05 pm@palamar prueba esto:
SELECT * FROM mytable WHERE mycolumn LIKE CONCAT('%', ?, '%')
Además creo que en las anteriores sentencias faltaba el LIKE
@palamar prueba esto:
SELECT * FROM mytable WHERE mycolumn LIKE CONCAT('%', ?, '%')
Además creo que en las anteriores sentencias faltaba el LIKE
Quote from Palamar on March 6, 2020, 8:37 pmSí, LIKE estaba, lo agregué despues de tu ejemplo....lo que faltaba en este caso creo que era la sentencia CONCAT y los paréntesis, ha funcionado con esta última. Muchas gracias @luishp y @gaev!!
Sí, LIKE estaba, lo agregué despues de tu ejemplo....lo que faltaba en este caso creo que era la sentencia CONCAT y los paréntesis, ha funcionado con esta última. Muchas gracias @luishp y @gaev!!