Page 1 of 1

Database - Specific Row and Column Retrieval

Posted: Mon Sep 28, 2009 5:39 pm
by Xombie
I searched and didn't see this but I'll apologize if it's been asked.

Can there be any change that would allow for a value to be returned from a specific column and row? For example, PosgreSQL allows you to pass a row and column to the PQgetvalue() function to return the value at a specific location.

I mean, yeah, it can be programmed around and made so that you do each row in order and don't need to pass the row but it's nice to have the option (when the database supports it) to get the value from a specific row & column.

Re: Database - Specific Row and Column Retrieval

Posted: Tue Sep 29, 2009 2:53 am
by Fangbeast
Using the reserved keyword of "rowid", I can use the following to go specifically to column 'mycolumn' in table 'mytable' in row 5 (if that's what you want?)

SELECT mycolumn FROM mytable WHERE rowid = 5

Re: Database - Specific Row and Column Retrieval

Posted: Tue Sep 29, 2009 10:22 am
by srod
Is that not SQLite only fangles?

Re: Database - Specific Row and Column Retrieval

Posted: Tue Sep 29, 2009 1:44 pm
by Fangbeast
srod wrote:Is that not SQLite only fangles?
As far as I am aware (and it's been a while I admit), it works on MySql as well. Don't have it handy to test but I seem to remember that rowid was a reserved SQL keyword and not a reserved SQLITE keyword.

But as I said, it's been a while.

I've been able to do this on old versions of MySQL (below) in the past to get a specific row (Don't know about now)..

SELECT mycolumn FROM mytable WHERE 5

Re: Database - Specific Row and Column Retrieval

Posted: Wed Sep 30, 2009 4:00 pm
by Xombie
Oh, no. I meant after a query like SELECT * FROM customers. But rather than going one row at a time and getting just the columns for that row you can select (with a function and not a SQL statement) any row and column value at any time during the execution of the statement.

I believe SQLite and PostgreSQL can both do this. Well, I know PGSQL can and SQLite can with the table thing, I think.