473,624 Members | 2,264 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sql query to fetch result

99 New Member
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 2131
coolsti
310 Contributor
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
robin1983
99 New Member
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 Recognized Expert Top Contributor
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 Contributor
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
5757
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 = mysql_result($result,$i,"ID"); $CompanyName = mysql_result($result,$i,"1"); $ContactName = mysql_result($result,$i,"2"); $Phone = mysql_result($result,$i,"3"); $HomePhone = mysql_result($result,$i,"4");
9
2456
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 if i run it from php i just get the first of the two results. Any ideas? Mysql 4.1.8 php 5.0.3
11
13739
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 01-Aug-2003
5
2334
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 contain a set of create, update, insert & delete statements (about 17500 lines including blank lines) that
8
21102
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 It took 14 seconds of CPU time to execute. After looking up the documentation on the FETCH FIRST notation I find "Limiting the result table to the first integer rows can improve performance. The database
1
1298
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 executed I need to postprocess the result. This postprocessing involves several queries on the result of q1. I think that the best solution would be to materialize the result of q1 in the database. How can I do it? Thanks a lot in advance!
7
3525
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 performs MySQL queries to a database. These queries are performed at regular intervals. Basically it is looking for fields that match certain criterias. Such fields are not present at all time. When the program finds such field, it then takes
1
4143
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 the first query? The first query uses the @exec_context and I am having a challenge trying to figure out how to make the call from within a different context and still insert into a #temp table. DECLARE @exec_context varchar(30) declare @sql...
1
13406
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 simply (select getdate) I want to fetch this query, evaluate it and then return the result of query. I tried to write a function like this,
0
8233
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8675
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8619
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.