1
It is possible to work with hyphenated columns (-
) within a select?
Example: SELECT fm-codigo, descricao FROM ems2cad.pub.familia
Progress database
I am performing the query using PHP via ODBC, already tried several means, how to use crase, simple quotes, brackets, keys but none solves, the results I get are errors saying that the column was not identified or no value returned.
Code used for testing below:
<html>
<head>
<title>Teste de relatórios</title>
</head>
<body>
<?php
$connect = odbc_connect('ems2cad', *user*, *pass*);
$sql = "SELECT fm-codigo, descricao FROM ems2cad.pub.familia";
$result = odbc_exec($connect , $sql);
?>
<table width=”600” height=”500”>
<tr>
<td>fm-codigo</td>
<td>descricao</td>
</tr>
<?php
while (odbc_fetch_row($result)) {
?>
<tr>
<td><?php echo odbc_result($result, 'fm-codigo');?></td>
<td><?php echo odbc_result($result, 'descricao');?></td>
</tr>
<?php
}
odbc_close($connect);
?>
</table>
</body>
</html>
It should work. Make sure you get data without using one of these fields, just as a test. My guess is that you’re not really connecting to the bank (am I an SQL connection for you? Can you get data from any table?).
– bupereira
@bupereira I can bring the information if I use select all, so yes, I am connected to the bank, however to treat these fields that have hyphenate in joins and clauses Where I need to be able to call them and that is where my difficulty lies. Another example, in this same code, if I let select so SELECT 'fm-codigo', Description, it returns me two columns, one repeating the values 'fm-codigo' and another bringing the values of the description that are in the database
– Matheus Souza