Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^5: Retrieving multiple records from database

by davido (Cardinal)
on Oct 17, 2004 at 15:41 UTC ( [id://399925]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Retrieving multiple records from database
in thread Retrieving multiple records from database

You have to build the column into your SQL statement. The first statement here will select all columns.

SELECT * FROM mytable WHERE age = ?

And this will select just one column:

SELECT firstname FROM mytable WHERE age = ?

In the case of the second SQL statement, fetchrow_array() will return an array of one single element.

There is a pretty good basic SQL tutorial at http://www.w3schools.com/sql/default.asp.

Another alternative is the $slice parameter of the fetchall_arrayref() method. By passing an anonymous arrayref containing the element numbers you're after, you can "slice" the arrayref for each row so that only certain columns are seen. This is documented in DBI.


Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://399925]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-28 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found