473,396 Members | 1,693 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,396 software developers and data experts.

Sql query to fetch result

Dear All,
How are you doing? After a long time I am back again because I need help from you all expert. Please advise me, my queries is given below.
I have a table with employee_name which contain the field name empFirstName, empLastName, empAges, empMinExp, empMaxExp, empCTC. Etc. The employee can only select only number with out any fraction value. Like 1, 2,3, 4,5 etc. So, the problem is that when I want to fetch result by parameter min and max value of the employee I am not able to fetch the exact result. Eg.
John Peru1 24 yrs Min: 1 yrs Max: 3 yrs 2Lacs
John Peru2 24 yrs Min: 1 yrs Max: 3 yrs 2Lacs
John Peru3 24 yrs Min: 1 yrs Max: 3 yrs 2Lacs
Kin Kum 25yrs Min: 3 yrs Max: 5 yrs 3Lacs
Dem Fu 23yrs Min: 2yrs Max: 3 yrs 4Lacs

If, I want fetch the employee which are having minimum experience 1yrs upto 3 yrs of experience. I write the query as below,

Select * from employee_name where empMinExp> 1 and empMaxExp<=3

but here the query also fetch employee who entered minimum experience as 3 yrs. So, I am not able to get the exact result as per my query. Please help me in resolving the solution. Thanking you in advance for you kind cooperation and supports.

Regards,
Robindra Singha
Jul 14 '08 #1
4 2120
coolsti
310 100+
Dear All,
How are you doing? After a long time I am back again because I need help from you all expert. Please advise me, my queries is given below.
I have a table with employee_name which contain the field name empFirstName, empLastName, empAges, empMinExp, empMaxExp, empCTC. Etc. The employee can only select only number with out any fraction value. Like 1, 2,3, 4,5 etc. So, the problem is that when I want to fetch result by parameter min and max value of the employee I am not able to fetch the exact result. Eg.
John Peru1 24 yrs Min: 1 yrs Max: 3 yrs 2Lacs
John Peru2 24 yrs Min: 1 yrs Max: 3 yrs 2Lacs
John Peru3 24 yrs Min: 1 yrs Max: 3 yrs 2Lacs
Kin Kum 25yrs Min: 3 yrs Max: 5 yrs 3Lacs
Dem Fu 23yrs Min: 2yrs Max: 3 yrs 4Lacs

If, I want fetch the employee which are having minimum experience 1yrs upto 3 yrs of experience. I write the query as below,

Select * from employee_name where empMinExp> 1 and empMaxExp<=3

but here the query also fetch employee who entered minimum experience as 3 yrs. So, I am not able to get the exact result as per my query. Please help me in resolving the solution. Thanking you in advance for you kind cooperation and supports.

Regards,
Robindra Singha
Don't you have something basically wrong with your table structure? What do the two columns mean, empMinExp and empMaxExp? Shouldn't this instead just be one column which states the employee's experience? Why would you store an minimum and maximum value for the employee?

A database is very powerful to deal with the data from our real world problems, and the database is most efficient and easiest to use when it's table structure correctly models our real world problem.
Jul 14 '08 #2
Don't you have something basically wrong with your table structure? What do the two columns mean, empMinExp and empMaxExp? Shouldn't this instead just be one column which states the employee's experience? Why would you store an minimum and maximum value for the employee?

A database is very powerful to deal with the data from our real world problems, and the database is most efficient and easiest to use when it's table structure correctly models our real world problem.
Thanks for the reply and suggestion. I really thank for the advice and I will take care from next time. But in the present scenario, what should be query, so that I can fetch only those employee which are having 1-3 yrs of experience not 3-5 yrs. please guide me.
Jul 14 '08 #3
amitpatel66
2,367 Expert 2GB
Thanks for the reply and suggestion. I really thank for the advice and I will take care from next time. But in the present scenario, what should be query, so that I can fetch only those employee which are having 1-3 yrs of experience not 3-5 yrs. please guide me.

Could you please post what you have tried so far?
Jul 14 '08 #4
coolsti
310 100+
I am afraid I don't understand where you are having problems.

Let us take this example:

One employee enters 1 for minimum experience and 3 for maximum experience.

Another employee enters 3 for minimum experience and 5 for maximum experience.

And you want a query that only selects the first person but not the second?

Then the query would be

Select * from employee_name where empMinExp> 1 and empMaxExp<=3

This would not select the second employee above because the query states that the "empMaxExp" field must be <= 3, and the second employee above has empMaxExp = 5.

But the Select query above is exactly the same that you showed in your original post.
Jul 14 '08 #5

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

Similar topics

4
by: Frank | last post by:
Can I store this PHP code in another page, then refernece it on multiple pages using Require or Include ??? //results from sql query for ($i=0; $i<$number; $i++) { $ID =...
9
by: Börni | last post by:
Hi, I have an sql query like this: SELECT column FROM table WHERE column1="3" AND column2="1" This query works perfectly if i run it in the command line, to be exactly it return two results. But...
11
by: Surajit Laha | last post by:
I am firing a query like: SELECT TaskName, StartDate FROMTasks WHERE StartDate >= '01-Aug-2003' Now the result comes as: TaskName StartDate -------------------------- Task1 ...
5
by: Glenn | last post by:
Hi! Server info - Win2K3 Server +SP1 with 1 GB Memory and 1.5 GB Virtual Memory SQL Server 2000 Enterprise Edition + SP3 running on this. Required result - Create a SQL Script that will...
8
by: Evan Smith | last post by:
During a routine performance check using an event monitor, I discovered a class of query whose performance has me baffled. The monitor captured: SELECT * FROM EWM_CASE fetch first 1 rows only...
1
by: gordongekko | last post by:
Hi! I'm writing a program that interacts with a db2 database through jdbc. I frequently need to run a quite query q1 that involves several full outer join of a table with itself. Once q1 is...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
1
by: santaferubber | last post by:
The first query returns me the results from multiple databases, the second does the same thing except it puts the result into a #temp table? Could someone please show me an example of this using...
1
by: CAG | last post by:
Hi, In my application, i'm storing sql query as value of table field in database. Like in my NewHireEmployee table, value of JoinDateQuery field can be (select hiredate from employeeInfo) or...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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
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.