我有一个像这样的查询
SELECT EmployeeName FROM Employee
查询结果将是:
Mr. Kamal
Mr. Karim
Mr. Rahim
Mr. Jamal
但是我需要 :
Mr. Kamal , Mr. Karim, Mr. Rahim, Mr. Jamal
是否可以通过单个查询。
我有一个像这样的查询
SELECT EmployeeName FROM Employee
查询结果将是:
Mr. Kamal
Mr. Karim
Mr. Rahim
Mr. Jamal
但是我需要 :
Mr. Kamal , Mr. Karim, Mr. Rahim, Mr. Jamal
是否可以通过单个查询。
你可以这样做:
# DATA SOURCE NAME
$dsn = "dbi:mysql:$database:localhost:3306";
# PERL DBI CONNECT
$connect = DBI->connect($dsn, $user, $pw);
# PREPARE THE QUERY
$query = "SELECT EmployeeName FROM Employee ORDER BY id";
$query_handle = $connect->prepare($query);
# EXECUTE THE QUERY
$query_handle->execute();
# BIND TABLE COLUMNS TO VARIABLES
$query_handle->bind_columns(undef, \$id);
# LOOP THROUGH RESULTS
while($query_handle->fetch()) {
print "$employeeName" ,;
}