473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

get selected column value for the last row in oracle db

45
hi all'

i m using php4 and oracle 9idb for my web-application.

i have got a problem .that is i just want to know how to get selected column value for the last row in table.

suppose i have employee table having 10 rows and 8 columns.Now i want to get the value for :column1,column5,column8 for the 10th(last row) no.of row.

How to do this in oracle,php..can anybody help me?

thanks
Apr 26 '08 #1
5 3327
ronverdonk
4,258 Expert 4TB
Easiest solution is to SELECT with a DESC ORDER BY. That way the last row will be the first one in the result set.

However, assuming you have not done a DESC order by, you can fetch all rows into an array and read the last row. Like[php]$norows = oci_fetch_all($statement, $results);
if ($norows > 0) {
$lastrow=$norows-1; // last row = no of rows - 1
$val1=$results[$lastrow][0]; // column 1
$val5=$results[$lastrow][4]; // column 5
$val8=$results[$lastrow][7]; // column 8
}[/php]Ronald
Apr 26 '08 #2
boss1
45
hi ,thank you for ur response.

but the code does not showing any output.
i wanted to show last row value for selective column by using"echo"
But it does not show any result.[php]$query5 = "SELECT * FROM depo_location_tbl";
$statement = ociparse ($c, $query5);
ociexecute ($statement);
$norows = ocifetchstatement($statement, $results);
if ($norows > 0) {
$lastrow=$norows-1; // last row = no of rows - 1
$val1=$results[$lastrow][0]; // column 1
$val5=$results[$lastrow][4]; // column 5
$val8=$results[$lastrow][7]; // column 8
}
echo"$val1";
echo"$val5";
echo"$val8";[/php]it does not give any output.
so can u plz..help in this problem.
May 6 '08 #3
ronverdonk
4,258 Expert 4TB
WARNING:
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
May 6 '08 #4
boss1
45
hi ,thank you for ur response.

but the code does not showing any output.
i wanted to show last row value for selective column by using"echo"
But it does not show any result.
[php]$query5 = "SELECT * FROM depo_location_tbl";
$statement = ociparse ($c, $query5);
ociexecute ($statement);
$norows = ocifetchstatement($statement, $results);
if ($norows > 0) {
$lastrow=$norows-1; // last row = no of rows - 1
$val1=$results[$lastrow][0]; // column 1
$val5=$results[$lastrow][4]; // column 5
$val8=$results[$lastrow][7]; // column 8
}
echo"$val1";
echo"$val5";
echo"$val8";[/php]
it does not give any output.
so can u plz..help in this problem.
May 7 '08 #5
ronverdonk
4,258 Expert 4TB
THIS IS THE LAST WARNING:
Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
May 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alvey Sidecast | last post by:
This is probably embarrassingly simple, but I've been trawling through this ng for hours now and my brain hurts. I've got an unbound multi-column listbox (multi-select=none) whose rowsource is a...
1
by: Suresh | last post by:
I have a datagrid. Datagrid column contains label's and list boxes. Populated seperately from database.( I am not using datagrid.Datasource) User click's a link button in the last column. I...
3
by: John Walker | last post by:
Hi, On an ASP.NET page I have a drop down list control. When the user pulls down the list and makes a selection, I perform validation, and if the validation fails I want the selected item in...
9
by: Leszek | last post by:
Hi. How can I get just one row from selected column and put it into html dropdown list I tried like this: function pobierz_wszystko($tabela,$kolumna) { $zapytanie="SELECT $kolumna FROM...
4
by: Smartin | last post by:
Good Day All, I am using Oracle 7.3. Using the following table definition and sample data, how can I obtain the PayID which has the maximum PayDate for each AccountID? table Payments...
2
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
2
by: cogitoergosum | last post by:
Hi, I have a table with four columns. By default, except for the second column (id="s01") all column values are protected. When a value is selected from second column, the third column is...
1
by: boss1 | last post by:
hello everyone, I am having a problem with populating second a drop down list depending on selected value of first drop down list. I have been searching the net for the last couple of days i...
2
by: meenuchotijuhi | last post by:
Hi, I've Recently joined this community coz i m very much interested in Oracle DBA track. Actaully I' m currently working on a project where I m using Java (jdk1.4) as front end and Oracle 9i as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.