Help with MYSQLi Query and WHILE statement
Hi,
Not sure what is wrong here but the same record is printed in the while loop 11 times (the amount of records in the table).
<?php
//Main Connection & Query
//Database Connection & Error
$con_host = 'X';
$con_username = 'X';
$con_password = 'X';
$con_database = 'X';
$con = mysqli_connect($con_host, $con_username, $con_password, $con_database);
?>
<?php
//Query
$sql = "SELECT * FROM equipment ORDER BY name ASC";
$query = mysqli_query($con, $sql);
$row = mysqli_fetch_assoc($query);
$row_count = mysqli_num_rows($query);
//Create Variables
$name = $row['name'];
$size = $row['size'];
$quantity = $row['quantity'];
$protection = $row['protection'];
$location = $row['location'];
$sublocation = $row['sublocation'];
$bc = $row['BC'];
$id = $row['id'];
?>
<!doctype html>
<html>
<link href="stylesheets/main_stylesheet.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Slabo+27px' rel='stylesheet' type='text/css'>
<!-- Favicon -->
<link rel="shortcut icon" type="image/png" href="images/icon.png" />
<style type="text/css">
</style>
<head>
<meta charset="utf-8">
<title>Print Equipment List</title>
<link href="stylesheets/print_stylesheet.css" rel="stylesheet" type="text/css">
<script src="sorttable.js"></script>
<!--<body onload="window.print()">-->
</head>
<body>
<div class="print_button no-print" onClick="window.print()">Print</div>
<div class="print_text no-print">Select the sorting of the list by clicking on the table categories and click the print button below</div>
<div class="print_a4page">
<div class="print_header">
<div class="print_header_logo"><img src="images/logo.png" width="306" height="43"></div>
<div class="print_header_text" id="header_text">Drama Database</div>
<div class="print_header_info">List printed: <script type="text/javascript">
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
document.write(day + "/" + month + "/" + year);</script>
<br>
Total records:
<?php echo $row_count ?></div>
</div>
<div class="print_header_divider">Equipment List</div>
<div class="print_body">
<div>
<form name="users" method="post">
<div class="table_print">
<table width="100%" border="0" cellpadding="5" class="sortable">
<tr class="table_header_print">
<th width="15%" scope="col">Name</th>
<th width="12%" scope="col">Size</th>
<th width="9%" scope="col">Quantity</th>
<th width="12%" scope="col">Protection</th>
<th width="17%" scope="col">Location</th>
<th width="12%" scope="col">Sublocation</th>
<th width="11%" scope="col">Barcode</th>
<th width="12%" scope="col">Internal ID</th>
</tr>
<?php do { ?>
<tr class="table_body">
<td><?php echo $name ?></td>
<td><?php echo $size ?></td>
<td><?php echo $quantity ?></td>
<td><?php echo $protection ?></td>
<td><?php echo $location ?></td>
<td><?php echo $sublocation ?></td>
<td><?php echo $bc ?></td>
<td><?php echo $id ?></td>
</tr>
<?php } while ($row = mysqli_fetch_assoc($query));?>
</table>
</form>
</div>
</div>
</div>
</body>
</html>
Still getting the same issue.
As I see it, the way you have suggested is just rearanging things right?
here is a screenshot of the outcome:
And here is the improved code:
<?php
//Main Connection & Query
//Database Connection & Error
$con_host = 'X';
$con_username = 'X';
$con_password = 'X';
$con_database = 'X';
$con = new mysqli($con_host, $con_username, $con_password, $con_database);
?>
<?php
//Query
$sql = "SELECT * FROM equipment ORDER BY name ASC";
$result = $con->query($sql);
$row = $result->fetch_assoc();
$row_count = $result->num_rows;
//Create Variables
$name = $row['name'];
$size = $row['size'];
$quantity = $row['quantity'];
$protection = $row['protection'];
$location = $row['location'];
$sublocation = $row['sublocation'];
$bc = $row['BC'];
$id = $row['id'];
?>
<!doctype html>
<html>
<link href="stylesheets/main_stylesheet.css" rel="stylesheet" type="text/css">
<link href='http://fonts.googleapis.com/css?family=Slabo+27px' rel='stylesheet' type='text/css'>
<!-- Favicon -->
<link rel="shortcut icon" type="image/png" href="images/icon.png" />
<style type="text/css">
</style>
<head>
<meta charset="utf-8">
<title>Print Equipment List</title>
<link href="stylesheets/print_stylesheet.css" rel="stylesheet" type="text/css">
<script src="sorttable.js"></script>
<!--<body onload="window.print()">-->
</head>
<body>
<div class="print_button no-print" onClick="window.print()">Print</div>
<div class="print_text no-print">Select the sorting of the list by clicking on the table categories and click the print button below</div>
<div class="print_a4page">
<div class="print_header">
<div class="print_header_logo"><img src="images/logo.png" width="306" height="43"></div>
<div class="print_header_text" id="header_text">Drama Database</div>
<div class="print_header_info">List printed: <script type="text/javascript">
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
document.write(day + "/" + month + "/" + year);</script>
<br>
Total records:
<?php echo $row_count ?></div>
</div>
<div class="print_header_divider">Equipment List</div>
<div class="print_body">
<div>
<form name="users" method="post">
<div class="table_print">
<table width="100%" border="0" cellpadding="5" class="sortable">
<tr class="table_header_print">
<th width="15%" scope="col">Name</th>
<th width="12%" scope="col">Size</th>
<th width="9%" scope="col">Quantity</th>
<th width="12%" scope="col">Protection</th>
<th width="17%" scope="col">Location</th>
<th width="12%" scope="col">Sublocation</th>
<th width="11%" scope="col">Barcode</th>
<th width="12%" scope="col">Internal ID</th>
</tr>
<?php while ($row = $result->fetch_assoc()) { ?>
<tr class="table_body">
<td><?php echo $name ?></td>
<td><?php echo $size ?></td>
<td><?php echo $quantity ?></td>
<td><?php echo $protection ?></td>
<td><?php echo $location ?></td>
<td><?php echo $sublocation ?></td>
<td><?php echo $bc ?></td>
<td><?php echo $id ?></td>
</tr>
<?php } ?>
</table>
</form>
</div>
</div>
</div>
</body>
</html>
Similar Messages
-
Weird problem with mysql query and data table buttons !!!!
Hi,
I'm using jsc 2 update 1 on windows and mysql 4.1 . I have a page with a data table. One column of the data table contains "Details" buttons.
Source query for the table is :
SELECT tbl_tesserati.idtbl_tesserati idTesserato,
tbl_tesserati.num_tessera,
tbl_tesserati.nome,
tbl_societa.codice_meccanografico
FROM tbl_tesserati
INNER JOIN tbl_rel_tesserato_discipline_societa ON tbl_tesserati.idtbl_tesserati = tbl_rel_tesserato_discipline_societa.id_tesserato
INNER JOIN tbl_cariche ON tbl_rel_tesserato_discipline_societa.id_carica = tbl_cariche.idtbl_cariche
INNER JOIN tbl_qualifiche ON tbl_rel_tesserato_discipline_societa.id_qualifica = tbl_qualifiche.idtbl_qualifiche
INNER JOIN tbl_discipline ON tbl_rel_tesserato_discipline_societa.id_disciplina = tbl_discipline.idtbl_discipline
INNER JOIN tbl_societa ON tbl_rel_tesserato_discipline_societa.id_societa = tbl_societa.idtbl_societa
LEFT JOIN tbl_province ON tbl_societa.provincia_sede_sociale = tbl_province.idtbl_province
LEFT JOIN tbl_comuni ON tbl_societa.comune_sede_sociale = tbl_comuni.idtbl_comuni
LEFT JOIN tbl_rel_tesserato_discipline_praticate ON tbl_rel_tesserato_discipline_praticate.tessera_id=
tbl_rel_tesserato_discipline_societa.idtbl_rel_tesserato_discipline
LEFT JOIN tbl_discipline_praticate ON tbl_discipline_praticate.idtbl_disciplina_praticate=tbl_rel_tesserato_discipline_praticate.disciplina_praticata_id
WHERE
tbl_tesserati.cognome LIKE ?
AND tbl_tesserati.nome LIKE ?
AND tbl_rel_tesserato_discipline_societa.id_societa LIKE ?
AND tbl_tesserati.idtbl_tesserati LIKE ?
AND tbl_cariche.idtbl_cariche LIKE ?
AND tbl_qualifiche.idtbl_qualifiche LIKE ?
AND tbl_tesserati.data_nascita >= ?
AND tbl_tesserati.data_nascita<= ?
AND tbl_discipline.idtbl_discipline LIKE ?
AND codice_affiliazione LIKE ?
AND tbl_societa.denominazione LIKE ?
AND YEAR(tbl_rel_tesserato_discipline_societa.data_scadenza) LIKE ?
AND (tbl_province.nome LIKE ? OR tbl_province.nome IS NULL)
AND ( tbl_comuni.nome LIKE ? OR tbl_comuni.nome IS NULL)
The tbl_tesserati.data_nascita is a mysql date field.
The click event handler code for the "Details" Button is:
public String btnModificaTesserato_action() {
try{
TableRowDataProvider rowData= (TableRowDataProvider)getBean("currentRowTesserati");
getRequestBean1().setId_tesserato((Long)rowData.getValue("idTesserato"));
} catch(Exception ex) {
log("errore nella query",ex);
return "dettaglioTesseratoSocieta";
}When i run the project and open the page the table is correctly rendered and populated with some rows. But when i click on details button nothing happens, the page is simply reloaded.
If i set a breakpoint in the code line TableRowDataProvider rowData= (TableRowDataProvider)getBean("currentRowTesserati");the debbuger does not stop the code execution ! As if the button was never clicked!
I tried to modify the source query to :
SELECT tbl_tesserati.idtbl_tesserati idTesserato,
tbl_tesserati.num_tessera,
tbl_tesserati.nome,
tbl_societa.codice_meccanografico
FROM tbl_tesserati
INNER JOIN tbl_rel_tesserato_discipline_societa ON tbl_tesserati.idtbl_tesserati = tbl_rel_tesserato_discipline_societa.id_tesserato
INNER JOIN tbl_cariche ON tbl_rel_tesserato_discipline_societa.id_carica = tbl_cariche.idtbl_cariche
INNER JOIN tbl_qualifiche ON tbl_rel_tesserato_discipline_societa.id_qualifica = tbl_qualifiche.idtbl_qualifiche
INNER JOIN tbl_discipline ON tbl_rel_tesserato_discipline_societa.id_disciplina = tbl_discipline.idtbl_discipline
INNER JOIN tbl_societa ON tbl_rel_tesserato_discipline_societa.id_societa = tbl_societa.idtbl_societa
LEFT JOIN tbl_province ON tbl_societa.provincia_sede_sociale = tbl_province.idtbl_province
LEFT JOIN tbl_comuni ON tbl_societa.comune_sede_sociale = tbl_comuni.idtbl_comuni
LEFT JOIN tbl_rel_tesserato_discipline_praticate ON tbl_rel_tesserato_discipline_praticate.tessera_id=
tbl_rel_tesserato_discipline_societa.idtbl_rel_tesserato_discipline
LEFT JOIN tbl_discipline_praticate ON tbl_discipline_praticate.idtbl_disciplina_praticate=tbl_rel_tesserato_discipline_praticate.disciplina_praticata_id
WHERE
tbl_tesserati.cognome LIKE ?
AND tbl_tesserati.nome LIKE ?
AND tbl_rel_tesserato_discipline_societa.id_societa LIKE ?
AND tbl_tesserati.idtbl_tesserati LIKE ?
AND tbl_cariche.idtbl_cariche LIKE ?
AND tbl_qualifiche.idtbl_qualifiche LIKE ?
AND tbl_tesserati.data_nascita >= ?
OR tbl_tesserati.data_nascita<= ?
AND tbl_discipline.idtbl_discipline LIKE ?
AND codice_affiliazione LIKE ?
AND tbl_societa.denominazione LIKE ?
AND YEAR(tbl_rel_tesserato_discipline_societa.data_scadenza) LIKE ?
AND (tbl_province.nome LIKE ? OR tbl_province.nome IS NULL)
AND ( tbl_comuni.nome LIKE ? OR tbl_comuni.nome IS NULL)
Using this query everything works well !! The click handler works and the debugger too !!
I changed only the AND in OR !!!
I also tried to change mysql-x-x-connector driver but without solving my problem.
Can someone help me ?
Thanks
GiorgioYou'll find that it is more to do with the way MySql deals with dates than anything else! Depending on how your date field is setup, then try using a BETWEEN statement for those 2 lines in your first query e.g.
AND ( tbl_tesserati.data_nascita BETWEEN ? AND ?)
The date column needs to be in the ISO format to work. If you examine your second query output, you might discover that the output is only going to refer to one parameter (probably the OR one). Did you manage to view the output logs from the application server? You would have got an idea from there with a message like stating a conversion error'.
Alternatively, you could try using the to_days() function and convert it directly to a number which would be a lot easier to deal with. For example:
AND to_days(tbl_tesserati.data_nascita >= ? )
AND to_days( tbl_tesserati.data_nascita<= ? )
Or try the BETWEEN version with to_days() and see what you get.
More info about date formatting (v5) here:
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days
Before I forget, sometimes you may need to treat dates as Strings rather 'Long' as you did.
As a matter of interest, did you try your query in a different piece of software?
If my queries are a little more complicated, I tend to try MySql queries out in the free MySql query browser and also double check in another to verify certain issues. I found it easier to develop SQL in a seperate program then import the final version to JSC making the required modifications for parameters.
Message was edited by:
aerostra -
Help with mysql query plz anyone i am begging!!!
Hi everyone pls forgive me i am new to java. can someone pls tel me where i am going wrong wit this mysql query?
<sql:query var="parish" maxRows="1" dataSource="jdbc/gav">
SELECT ParishName, OwnerOccupierHousehold, OwnerOccupierPercOfOverall, OwnerOccupierCo2Emissions,
SocialRentedHousehold, SocialRentedPercOfOverall, SocialRentedCo2Emissions, PrivateRentedHousehold,
PrivateRentedPercOfOverall, PrivateRentedCo2Emission, TotalHouseholds, TotalPerc, Average,
Total2001, TotalEstimatedTotal2006, EmissionsPerPerson, EmissionPerHousehold, EmissionsPerParish,
EnergyChampionsNeeded, NumberOfPeopleAtWork, NumberOfSchoolAgeChildren
FROM base_data as b
WHERE b.id = ? <sql:param value="${param.id}"/>
<sql:param value="${param.id}"/>
</sql:query>
<c:set var="parish" scope="request" value="${parish.rows[0]}"/>
here is the error i get:
java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).
please any help would be appreciated!!! Thanks in advance guys .here is my code for the form on the index page:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:query var="parish" dataSource="jdbc/gav">
SELECT id, ParishName FROM base_data
</sql:query>
<form action="response.jsp">
Select a Parish: <select name="id">
<c:forEach var="parish" items="${parish.rows}">
<option value="${parish.id}">${parish.ParishName}</option>
</c:forEach>
</select><br><input type="submit" value="submit" name="submit" /></form>
here is the code for the response page:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:query var="parish" maxRows="1" dataSource="jdbc/gav">
SELECT b.id, b.ParishName, b.OwnerOccupierHousehold, b.OwnerOccupierPercOfOverall, b.OwnerOccupierCo2Emissions,
b.SocialRentedHousehold, b.SocialRentedPercOfOverall, b.SocialRentedCo2Emissions, b.PrivateRentedHousehold,
b.PrivateRentedPercOfOverall, b.PrivateRentedCo2Emission, b.TotalHouseholds, b.TotalPerc, b.Average,
b.Total2001, b.TotalEstimatedTotal2006, b.EmissionsPerPerson, b.EmissionPerHousehold, b.EmissionsPerParish,
b.EnergyChampionsNeeded, b.NumberOfPeopleAtWork, b.NumberOfSchoolAgeChildren
FROM base_data as b
WHERE b.id = ? <sql:param value="${param.id}"/>
</sql:query>
<c:set var="parish" scope="request" value="${parish.rows[0]}"/>
i display the results like this : ${parish.EmissionsPerParish}
the user should be able to select a parish from a form and then sql query created and then i want to show the row results on the response page.
could you tell me where so should be a simple process although not simple enough as it may seem.
thanks for the advice keith -
Need help with MySQL Query...Again
Ok so I get this error when I enter "springfield" and "MA" for the city and state.
This server program accepts either a 'zipcode' or 'city, state' depending on the choice # passed to it.
I just need to be able to perform the query.
Thanks!!
java.sql.SQLException: Unknown column 'springfield' in 'where clause'
Error4
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2975)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1600)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1695)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3020)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2949)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:959)
at ThreadConnect.run(ZipcodeServer.java:84)Here is my code:
import java.sql.*;
import java.io.*;
import java.net.*;
public class ZipcodeServer {
static void runServer() {
ServerSocket server;
Socket connection;
try {
System.out.println("Creating Server Socket " + 5000 + " . . . ");
server = new ServerSocket(5000);
System.out.println("SUCCESS!!!");
while (true) {
System.out.println("Waiting for connection.");
connection = server.accept();
System.out.println("Done");
ThreadConnect t = new ThreadConnect(connection);
t.start();
} catch (IOException e) {
System.out.println("Error5");
e.printStackTrace();
public static void main(String args[]) {
ZipcodeServer.runServer();
class ThreadConnect extends Thread {
Socket connection;
DataOutputStream output;
DataInputStream input;
ThreadConnect(Socket x) {
connection = x;
public void run() {
try {
input = new DataInputStream(connection.getInputStream());
output = new DataOutputStream(connection.getOutputStream());
try {
int choice = input.readInt();
String city, state;
int zipcode;
if (choice == 1) {
int zc = input.readInt();
DatabaseConnection.connect();
DatabaseConnection.rs = DatabaseConnection.s
.executeQuery("SELECT City,State FROM Zipcodes "
+ "WHERE ZipCode = " + zc);
while (DatabaseConnection.rs.next()) {
state = DatabaseConnection.rs.getString("State");
output.writeUTF(state);
output.flush();
city = DatabaseConnection.rs.getString("City");
output.writeUTF(city);
output.flush();
} else if (choice == 2) {
city = input.readUTF();
state = input.readUTF();
DatabaseConnection.connect();
DatabaseConnection.rs = DatabaseConnection.s
.executeQuery("SELECT ZipCode FROM Zipcodes "
+ "WHERE City = " + city + " AND State = "
+ state);
while (DatabaseConnection.rs.next()) {
zipcode = DatabaseConnection.rs.getInt("ZipCode");
output.writeInt(zipcode);
output.flush();
} catch (Exception e) {
System.out.println("Error4");
e.printStackTrace();
} finally {
DatabaseConnection.close();
} catch (IOException e) {
System.out.println("Error3");
e.printStackTrace();
class DatabaseConnection {
static Connection con;
static Statement s;
static ResultSet rs;
static String driver = "com.mysql.jdbc.Driver";
static String url = "jdbc:mysql://***.****.******/***";
static String user = "*******";
static String password = "********";
static void connect() {
try {
Class.forName(driver).newInstance();
System.out.println("Loaded Driver");
con = DriverManager.getConnection(url, user, password);
System.out.println("Connected to database\n");
con.setAutoCommit(false);
s = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
} catch (Throwable e) {
System.out.println("Error2");
e.printStackTrace();
static void close() {
try {
rs.close();
s.close();
con.close();
System.out.println("\nDisconnected From Database");
} catch (Throwable e) {
System.out.println("Error1");
e.printStackTrace();
}R.Baldwin7 wrote:
I tried it. Still getting the same error.
Code no looks like:
else if (choice == 2) {
city = input.readUTF();
state = input.readUTF();
DatabaseConnection.connect();
PreparedStatement ps = DatabaseConnection.con.prepareStatement("SELECT ZipCode FROM Zipcodes "
+ "WHERE City = " + city + " AND State = "
+ state);
DatabaseConnection.rs = ps.executeQuery();
while (DatabaseConnection.rs.next()) {
zipcode = DatabaseConnection.rs.getInt("ZipCode");
output.writeInt(zipcode);
output.flush();
Read the API docs and the JDBC Tutorials for the proper way to use a PreparedStatement. It may "work" to add the quotes, but it is definately not the right way to do it. What happens if the city entered contains an apostrophe? Your statement will be broken again. Like I said, use a PreparedStatement and use it right. -
Help with image query and display
I want to show clients a few proofs. I've created a dropdown
list of Projects. That calls a CFC query to search for the related
image names within the DB. The images are stored locally/within my
Flex Application File Folder Structure. After querying the DB I
need it to return the list of images, and then display them from
the folder location. Can this be done and how? So far I can't even
get my CFC to return an Alert.show(imageList).toString(); So... I
missing something somewhere. I had to change the returntype to
query... but I've got a variable set as an imageList:image;??? Any
help or comments would be greatly appreciated!The validator gives sound information about most
non-compliant code. For
example, the No Doctype error is an easy fix, and will
eliminate many of the
others.
Have you done anything to fix the problems ? Take the errors
one at a time
and please let us know each one you have difficulty with. You
will have to
learn some CSS to resolve some of the "errors".
"rachel_c" <[email protected]> wrote in
message
news:fj9gkv$pv4$[email protected]..
> Hello all,
> Would anyone help me in correcting the error codes on my
internet site :
>
http://jeanmichel.labarre1.free.fr
>
> I have had a look to recommendations about using the
>
http://validator.w3.org/
> but I have absolutely no idea of what changes I must
make in the code.
> I have used dreamweaver 8 and do not know much about
coding.
> The problems I encounter is that the display is
incorrect in netscape,
> mozilla... (lots of space in between text) whereas it
appears correctly in
> IE 6.
>
> Thanks a lot for your time!
> Rachel
>
> -
Need Help with complex query and computing values
I have an issue trying to combine data from several tables. I need help trying to compute the "Total Hours", "Max Pressure" ,"Average Pressure" while displaying the "Manufacturer",
"Part Type" , "Serial Number", "District", "Status","Truck Type",and "truck number" for a certain Part on all Trucks. I need to be able check and see if the serial number was on
a particular job and calculate the hours of that serial number if it was on that job and the jobdate falls between the install date and removal date. Ive tried but keep getting either
repeating rows, total hrs of the truck instead of the serial number. Ive considered doing a pivot to display it but have been having trouble putting it together.
table 1
(*records of parts*)
Contains serial number,truck number, part type, part number, install date, removal date, status
table 2
(*records of Jobs*)
contains Jobnumber, JobStartdate, Max pressure, average pressure, and Totalhrs
table 3
(records related to jobs and trucks)
contains jobnumber, district , and truck numbers
Table 4
(records of manufacturers and part numbers)
contains partnumber, manufacturer name, and truck type
I would like to get it to show like below
SerialNo PrtType
MFG TruckNo
TrkType TtlHrs
MaxPr AvgPr
Status
Dst
AB345 1200series
NGK 2G34
Boss X 400 10,000
9500 NonOp
NE
Thanks in advanceHope this helps
Note: (Date of Mar 1 2014 was just extended to a further date so the system would know that its still operating when calculating current hours)
Table 1
SerialNo TruckNo InstallDate RemovalDate Status PartNo PartType
BJ1002 F917 2013-09-17 2014-03-01 Oper L871235 BJ 3000 GL
CWS1002 F104 2012-11-21 2013-03-29 NonOper L76088-450 CWS 2000
CWS1003 F104 2013-04-24 2013-08-01 NonOper L76088-450 CWS 2000
CWS1005 F187 2012-11-21 2013-04-04 NonOper L76088-450 CWS 2000
CWS1006 F187 2013-04-24 2013-06-30 NonOper L76088-450 CWS 2000
CWS1007 F187 2013-06-30 2013-03-01 Oper L76088-450 CWS 2000
CWS1009 2F60 2013-05-05 2013-03-01 Oper L76088-450 CWS 2000
CWS1011 F809 2013-05-28 2013-08-28 NonOper L76088-400 CWS 2000
CWS1013 F990 2013-06-11 2013-10-29 NonOper L76088-450 CWS 2000
CWS1015 F783 2013-06-28 2013-03-01 Oper L76088-450 CWS 2000
Table 2
JobNumber Date District PrAvTreat PrMaxTr TotalHrs
553811287 2012-01-19 Fairmount 7337 8319 1.53
652110088 2012-08-20 San Antonio 6340 7075 0.47
652110090 2012-08-21 San Antonio 6134 7131 0.62
652110091 2012-08-22 San Antonio 6180 2950 0.58
652110092 2012-08-23 San Antonio 5959 6789 0.64
652110093 2012-08-23 San Antonio 6165 7466 0.62
Table 3
TruckNo District JobNumber
1F01 Odessa 10011012329
1F01 Odessa 10011012333
1F01 Odessa 10011014831
1F01 Odessa 10011014834
1F01 Odessa 10011012332
1F01 Odessa 10011012328
1F01 Odessa 10011014829
Table 4
PartNumber Manufacturer TruckType
L322020-2 Jimmy Dean Ford T
L322738-2 Lucas Ford T
L47869-1 Jimmy Dean Ford T
L76070-650 NGK Ford T
Sam Howard -
I am trying to return results between a year or 365 days. I need to run this at any time and return a year prior. I'm not getting any results? Any help? THX!
SELECT
NAME.ID,
Activity.UF_2,
Name.FIRST_NAME,
Name.LAST_NAME,
Name.EMAIL,
Activity.TRANSACTION_DATE
FROM
Activity INNER
JOIN Name
ON Activity.ID
= Name.ID
Where
activity.TRANSACTION_DATE
BETWEEN
CAST(CAST(DATEADD(DAY,
-365,
GETDATE())
AS
DATE)
AS
DATETIME)
AND
DATEADD
(SECOND,
-1,
DATEADD(DAY,
1,
CAST(CAST(DATEADD(DAY,
-365,
GETDATE())
AS
DATE)
AS
DATETIME)))
and Activity.UF_1
=
'a'
and Activity.UF_2
=
'NAT'Where activity.TRANSACTION_DATE >= DATEADD(YEAR, -1, GETDATE()) AND activity.TRANSACTION_DATE < GETDATE()
-
I need help with this code error "unreachable statement"
the error_
F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
int index;
^
F:\Java\Projects\Tools.java:71: missing return statement
}//end delete method
^
F:\Java\Projects\Tools.java:86: missing return statement
}//end getrecod
^
3 errors
import java.util.*;
import javax.swing.*;
import java.awt.*;
public class Tools//tool class
private int numberOfToolItems;
private ToolItems[] toolArray = new ToolItems[10];
public Tools()//array of tool
numberOfToolItems = 0;
for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
toolArray[i] = new ToolItems();
}//end for loop
}//end of array of tools
public int search(int id)//search mehtod
int index = 0;
while (index < numberOfToolItems)//while and if loop search
if(toolArray[index].getID() == id)
return index;
else
index ++;
}//en while and if loop
return -1;
}//end search method
public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
if(numberOfToolItems >= toolArray.length)
return 0;
int index;
index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
if (index == -1)
toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
numberInStock ++;
return 1;
}//end if index
}//end if toolitem array
return -1;
}//end insert method
public int delete(/*int id*/)//delete method
}//end delete method
public void display()//display method
for(int i = 0; i < numberOfToolItems; i++)
//toolArray.display(g,y,x);
}//end display method
public String getRecord(int i)//get record method
// return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
}//end getrecod
}//end class
Edited by: ladsoftware on Oct 9, 2009 6:08 AM
Edited by: ladsoftware on Oct 9, 2009 6:09 AM
Edited by: ladsoftware on Oct 9, 2009 6:10 AM
Edited by: ladsoftware on Oct 9, 2009 6:11 AMladsoftware wrote:
Subject: Re: I need help with this code error "unreachable statement"
F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
int index;
^
F:\Java\Projects\Tools.java:71: missing return statement
}//end delete method
^
F:\Java\Projects\Tools.java:86: missing return statement
}//end getrecod
^
3 errorsThe compiler is telling you exactly what the problems are:
public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
if(numberOfToolItems >= toolArray.length)
return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
int index;
index = search(id); //< -----------------------------------------------------------------------------------------------------------------HERE
if (index == -1)
toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
numberInStock ++;
return 1;
}//end if index
}//end if toolitem array
return -1;
}//end insert method
public int delete(/*int id*/)//delete method
// <<== HERE where is the return statement?
}//end delete method
public String getRecord(int i)//get record method
// return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
}//end getrecod
}//end class -
Need help with SQL Query with Inline View + Group by
Hello Gurus,
I would really appreciate your time and effort regarding this query. I have the following data set.
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
Please Ignore '----', added it for clarity
I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
The query should return the following data set
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
The following is my query. I am kind of lost.
select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
from (
select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
from INVOICE
group by sequence_id,check_date, check_number, invoice_number, vendor_number
) A, INVOICE B
where A.sequence_id = B.sequence_id
Thanks,
NickIt looks like it is a duplicate thread - correct me if i'm wrong in this case ->
Need help with SQL Query with Inline View + Group by
Regards.
Satyaki De. -
Need urgent help with the query - Beginer
Hello - I need help with a query to populate data in a table.Here is the scenario.
Source1
MnthID BranchCod CustID SegCode FXStatus ProfStatus Profit
200712 B1 C1 20 Y Y 100
Source2
MnthID BranchCod CustID ProdCode ProdIndex
200712 B1 C1 12 1
200712 B1 C2 12 0
Destination
MnthID BranchCod SegCode ProdCode CountSegCust CountProdCust ProfitProdCust
Condition and Calculations:
1)Source1 customer are base customers.If Source2 has customers who is not in source1 then that customer's record should not be fetched.
2)SegCode, FX Status, ProfStatus is one variable in destination table. [ SegCode = SegCode+ FXStatus (if FXStatus = Y)+ ProfStatus (if FXStatus = Y) ]
3)CountSegCust = CountCustID Groupby MnthID,BranchCod,SegCode Only.
4)CountProdCust = CountCustID Groupby MnthID,BranchCod,SegCode,ProdCode (when ProdIndex = 1)
5)ProfitProdCust = Sum of Profit of Customers Groupby MnthID,BranchCod,SegCode,ProdCode (when ProdIndex = 1)
Apologies for bad formatting.
Thanks in advance!!A total guess indeed.
It's not clear whether some aggregation can be done (summing counts of grouped data might cause some customers being counted more than once)
insert into destination
select mnthid,branchcod,segcode,prodcode,countsegcust,countprodcust,profitprodcust
from (select s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end segcode,
s2.prodcode,
count(s1.custid) over (partition by s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end
order by null
) countsegcust,
count(case proindex when 1
then custid
end
) over (partition by s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end
s2.prodcode
order by null
) countprodcust,
sum(case proindex when 1
then profit
end
) over (partition by s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end
s2.prodcode
order by null
) profitprodcust,
row_number() over (partition by s1.mnthid,
s1.branchcod,
s1.segcode || case s1.fxstatus when 'Y' then s1.fxstatus || s1.profstatus end
s2.prodcode
order by null
) the_row
from source1 s1,source2 s2
where s1.mnthid = s2.mnthid
and s1.branchcod = s2.branchcod
and s1.custid = s2.custid
where the_row = 1Regards
Etbin -
Please, need help with a query
Hi !
Please need help with this query:
Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
select distinct a.id,
create_date,
a.loanid,
a.rate,
a.pays,
a.gracetime,
a.emailtosend,
d.first_name,
d.last_name,
a.user_id
from CLAL_LOANCALC_DET a,
loan_Calculator b,
bv_user_profile c,
bv_mr_user_profile d
where b.loanid = a.loanid
and c.NET_USER_NO = a.resp_id
and d.user_id = c.user_id
and a.is_partner is null
and a.create_date between
TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
order by a.create_dateTake a look on the syntax :
max(...) keep (dense_rank last order by ...)
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#i1000901
Nicolas. -
Please need help with this query
Hi !
Please need help with this query:
Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
select distinct a.id,
create_date,
a.loanid,
a.rate,
a.pays,
a.gracetime,
a.emailtosend,
d.first_name,
d.last_name,
a.user_id
from CLAL_LOANCALC_DET a,
loan_Calculator b,
bv_user_profile c,
bv_mr_user_profile d
where b.loanid = a.loanid
and c.NET_USER_NO = a.resp_id
and d.user_id = c.user_id
and a.is_partner is null
and a.create_date between
TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
order by a.create_datePerhaps something like this...
select id, create_date, loanid, rate, pays, gracetime, emailtosend, first_name, last_name, user_id
from (
select distinct a.id,
create_date,
a.loanid,
a.rate,
a.pays,
a.gracetime,
a.emailtosend,
d.first_name,
d.last_name,
a.user_id,
max(create_date) over (partition by a.user_id, a.loadid) as max_create_date
from CLAL_LOANCALC_DET a,
loan_Calculator b,
bv_user_profile c,
bv_mr_user_profile d
where b.loanid = a.loanid
and c.NET_USER_NO = a.resp_id
and d.user_id = c.user_id
and a.is_partner is null
and a.create_date between
TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
where create_date = max_create_date
order by create_date -
I created a blogging tool for my students to use as I teach
them internet safety and cyber citizenship. I am no CF master, but
I dabble a little bit here and there. I need some help with this
query. It is running extremely slow, which means I have probably
created some horrendous loop in this query. If any one out there
has a better solution for this query, I and my middle school
students would be extremely grateful.
Here's what I would like it to do. I have two tables, one for
the blog messages and another for comments. The comments are linked
to their respective blog messages through a common database field.
When someone clicks on a link to read a student's blog, a query
runs which pulls all of the blog messages for that user, the
comments, and it also counts the number of comments entries for
each message so that I can place a total # of comments under each
blog message.Not sure why you have this like this: (Select
count(commentid) from comments where comments.blogid = blog.blogid)
or this twice: blog.blogusersid = #fname#
You need to make sure that the comments.blogid and
blog.blogid fields are indexed. Does this query work any faster?
<cfquery Name="Myblog" datasource="blog">
SELECT b.blogid, b.btitle, b.bcontent, b.bdate,
b.blogusersid, b.fname, b.lname, b.blogpict, b.pictlocation,
b.userid, c.commentid, c.blogid, b.lastupdated, COUNT(c.commentid)
AS cc
FROM blog AS b
INNER JOIN comments AS c ON c.blogid = b.blogid
WHERE b.blogusersid = #fname#
GROUP BY b.blogid, b.btitle, b.bcontent, b.bdate,
b.blogusersid, b.fname, b.lname, b.blogpict, b.pictlocation,
b.userid, c.commentid, c.blogid, b.lastupdated
ORDER BY b.bdate
</cfquery>
..... but I'm not sure that you will be getting the comment
count that you want with either query.
Phil -
Hi guys can someone help with a query regarding the 'podcast app' why do they not have all the episodes that relate to one show available why only half or a selected amount
THanks...but some days they have all the episodes right back to the very first show...ive downloaded a few but they are only available every now and then which makes no sense...why not have them available the whole time ??
-
Need help with Blog, Wiki and Gallery
Hi Team,
Need help with Blog, Wiki and Gallery startup. I have newly started visiting forums and quite interested to contribute towards these areas also.
Please help.
Thanks,
Santosh Singh
Santosh SinghHello Santhosh,
Blog is for Microsoft employees only. However, you can contribute towards WIKI and GALLERY using the below links.
http://social.technet.microsoft.com/wiki/
http://gallery.technet.microsoft.com/
Maybe you are looking for
-
Is there a way to insert a link to a PDF or other non-webpage object?
I would like to create a project plan and have one of the rows refer to a PDF that is not on the web - it is on my hard drive. Is there a way to use the hyperlink function or some other Insert command to do this - or some other solution you can sugge
-
I am new to WebLogic, and have been trying to get it setup to serve JSP files. I followed the instructions in the documentation. However, when I try to access a JSP, I get the following errors. It looks like my java compiler doesn't like the syntax W
-
What is the best way to zoom in and out of pictures, documentary style?
I'm new to Adobe Premiere and I was looking to a make a mock documentary in which there would be slow zoom in's of photo's while the narrator is talking. If you could imagine what I'm talking about. Could anyone tell me how you would accomplish that?
-
2-Way Materialized View Replication
Dear All, i want to know if it is possible to configure 2-way Replication with Materailized view Replication e.g if i had EMP table at master site and MV EMP_MV at materialized view site if i update EMP table in master site ,then EMP_MV is updated au
-
Please provide the link to download WINDOWS 9 ISO
Hi All, Please provide the correct URL to download Windows 9 ISO?? Thanks, Prabha G