473,473 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

what is the error in query

27 New Member
hi,
I am explain now Database structure.

Database Name:- FLB
Tables :- Offence

offence table contains following fields
FirstName,LastName,Position,HR,RBI,SB,AVG,Ts.

my problem is,
I'm submitting the range values for HR,RBI,SB,AVG according to my requirment
e.g.HR- 10-50,RBI- 50-100,SB- 60-100,AVG - 0.5-1.0
and I want to display all the user for required position from table offense.

My query for 'C' position is as fallow,

query = "select * from Offense where Position='C' or OtherPos1='C' or OtherPos2='C' or OtherPos3='C' and HR between " + hrvi1 + " and " + hrvi2 + " and RBI between " + rbivi1 + " and " + rbivi2 + " and SB between " + sbvi1 + " and " + sbvi2 + " and AVG between " + avgvi1 + " and " + avgvi2 + " order by Ts DESC";


Will you please tell me,What is the mistake in this query?Because I unable to find required records.OR you may suggest new query instead of this query.


Thank,
VIkas Sawant.
Mar 11 '09 #1
5 1671
Jibran
30 New Member
What is OtherPos1, OtherPos2 and OtherPos3? I don't see their definition. Would you be able to post the entire script.
Mar 11 '09 #2
debasisdas
8,127 Recognized Expert Expert
Are you getting any error ?

do you have the data as per your requirement in your table ?
Mar 12 '09 #3
vikassawant
27 New Member
Thanks for reply.

Offence table contains following fields FirstName,LastName,Position,otherpos1,otherpos2,ot herpos3,HR,RBI,SB,AVG,Ts.

My query for 'C' position is as fallow,

query = "select * from Offense where Position='C' or OtherPos1='C' or OtherPos2='C' or OtherPos3='C' and HR between " + hrvi1 + " and " + hrvi2 + " and RBI between " + rbivi1 + " and " + rbivi2 + " and SB between " + sbvi1 + " and " + sbvi2 + " and AVG between " + avgvi1 + " and " + avgvi2 + " order by Ts DESC";

this query display all records for 'C' position not which follows the range values for hr,rbi,sb and avg.

This is what the problem I am facing.

Thanks
Vikas Sawant
Mar 12 '09 #4
Jibran
30 New Member
I'll recommend if you break this query down to a query and a subquery. Something like:

select * from
(select * from offence where HR between " + hrvi1 + " and " + hrvi2 + " and RBI between " + rbivi1 + " and " + rbivi2 + " and SB between " + sbvi1 + " and " + sbvi2 + " and AVG between " + avgvi1 + " and " + avgvi2 + ")
where Position='C' or OtherPos1='C' or OtherPos2='C' or OtherPos3='C' and order by Ts DESC.

First make sure, the innner query is generating results then focus on the outer one.
Mar 12 '09 #5
vikassawant
27 New Member
thanks Jibran and all of you ,

This is really nice Forum.

I got the solution.I just change the way of execution of this query.

Now query is as fallow,

query = "select * from Offense where HR between "+hrvi1+" and "+hrvi2+" and RBI between "+rbivi1+" and "+rbivi2+" and SB between "+sbvi1+" and "+sbvi2+" and AVG between "+avgvi1+" and "+avgvi2+" and Position='O' or OtherPos1='O' or OtherPos2='O' or OtherPos3='O' order by Ts DESC";


Thanks,
Vikas Sawant
Mar 12 '09 #6

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

Similar topics

3
by: lawrence | last post by:
If I do something like : $result = mysql_query($query); $dbArray = dbResultIntoKeyArray($result); and this is the function: function dbResultIntoKeyArray($result) {
8
by: Polar | last post by:
I am having troubles finding the parse error in this script. I've been checking for weeks. I am too new to the subject I guess. I am trying to show a readord and them have a form at the bottom...
5
by: lkrubner | last post by:
I have a webserver through Rackspace. I create a domain. I create an FTP user. I upload some files. I create a database called testOfSetupScript and then I create a database user named setup. I...
0
by: Morten Gulbrandsen | last post by:
C:\mysql\bin>mysql -u elmasri -pnavathe company Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 29 to server version: 4.1.0-alpha-max-debug Type...
3
by: user_5701 | last post by:
Hello, I'm getting an error with a Docmd.Transferspreadsheet line of code: DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel2000, "tblTest", pathAndFilename, True The above line...
4
by: darrel | last post by:
I'm still struggling to find out why I keep getting Invalid object name 'monkey'. errors. Below is my try/catch statement. Note the first query is trying to delete a record in the table...
2
by: paranic | last post by:
Hi there i suppose we have the following class file database.php class InSQL { function query($query, $link_identifier=null) { global $query_totals;
1
by: Dot Net Daddy | last post by:
Hi, I am new to MS-SQL and I have a problem. Actually I have made similar queries on Oracle, but now I failed on MS Sql. First of all I am using SQL Server 2005, but I think it is not that much...
10
by: bobf | last post by:
I am using a program 'My Contact Table' which is a code generator program. It allows you to easily create a PHP/MySQL web application without writing any code. I am trying to create an additional...
0
by: .nLL | last post by:
Erorr is --------------------- Microsoft VBScript runtime error '800a0046' Permission denied /a.asp, line 3 -----------------------
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.