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

subquery

12
hi
i have the below query that is not working .

select gro_code,grp_name from groups
where exists
(select * from groups where len(gro_code)<5)
i want to get all data in groups where no# of digits in gro_code<5
Apr 12 '08 #1
6 1466
FishVal
2,653 Expert 2GB
hi
i have the below query that is not working .

select gro_code,grp_name from groups
where exists
(select * from groups where len(gro_code)<5)
i want to get all data in groups where no# of digits in gro_code<5
Hi, dmcp.

Won't a simple SELECT query with criteria for gro_code "length" do the job?
BTW, a more effective criteria (<5 digits) for positive integers interpreted as decimals looks like:
gro_code < 100000.

Kind regards,
Fish
Apr 12 '08 #2
dmcp
12
thanks for the hint
but i was wondering why the query didn't work
Apr 12 '08 #3
FishVal
2,653 Expert 2GB
What do you mean saying "the query didn't work"?
Apr 12 '08 #4
dmcp
12
i have an unbound form with 2 multiselect list boxes. grp & io.
the IO listbox is unbound and depends on the grp listbox but after finishing from the grp listbox i'm getting a null IO listbox.
the below code is tested and ok.

Dim V As Variant
Dim GRPS As String

If Me.grp.ItemsSelected.Count > 0 Then
For Each V In Me.grp.ItemsSelected
GRPS = GRPS & Me.grp.ItemData(V) & ","
Next V
GRPS = Left$(GRPS, Len(GRPS) - 1)
End If

If Len(GRPS) = 0 Then
GRPS = "like '*'"
Else
GRPS = "IN(" & GRPS & ")"
End If

SQLSTR = "SELECT internal_orders.ior_no, internal_orders.ior_description,internal_orders.io r_date, "
SQLSTR = SQLSTR & " internal_orders.io_grp FROM internal_orders "
SQLSTR = SQLSTR & " WHERE internal_orders.io_grp " & GRPS

Me.io.RowSource = SQLSTR
Apr 12 '08 #5
dmcp
12
What do you mean saying "the query didn't work"?
the original query that i sent gives no data . i didn't know what's wronge with it
Apr 12 '08 #6
FishVal
2,653 Expert 2GB
the original query that i sent gives no data . i didn't know what's wronge with it
Me too. ))

Expand|Select|Wrap|Line Numbers
  1. select gro_code,grp_name from groups 
  2. where exists 
  3. (select * from groups where len(gro_code)<5) 
  4.  
The query is expected to return all or no records depending on whether [gro_code] value in ANY record of [groups] table satisfies given criteria or it doesn't. This happens because ambiguous field name - gro_code, could be related to main query and subquery source table. In this particular case Access by default associates [gro_code] with subquery source table.

To disambiguate this you need to give one of the table instance an alias name and use it to explicitly refer to the field.

Expand|Select|Wrap|Line Numbers
  1. select gro_code,grp_name from groups as groups_alias
  2. where exists 
  3. (select * from groups where len(groups_alias.gro_code)<5) 
  4.  
But in this case a simple query .
Expand|Select|Wrap|Line Numbers
  1. select gro_code,grp_name from groups
  2. where len(gro_code)<5
  3.  
will do the same for less money.

Regards,
Fish
Apr 12 '08 #7

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

Similar topics

2
by: lev | last post by:
CREATE TABLE . ( NULL , , (44) ) ID is non-unique. I want to select all IDs where the last entry for that ID is of type 11.
7
by: Andrew Mayo | last post by:
Here's a really weird one for any SQL Server gurus out there... We have observed (SQL Server 2000) scenarios where a stored procedure which (a) begins a transaction (b) inserts some rows into...
0
by: Greg Stark | last post by:
Postgresql 7.4b2 (approximately, compiled out of CVS) When I have a subquery that has a complex subquery as one of the result columns, and then that result column is used multiple times in the...
8
by: Venkata C | last post by:
Hi! Does anyone here know of a way to goad DB2 into converting a correlated subquery to a non-correlated one? Does DB2 ever do such a conversion? We have a query of the form SELECT .. FROM A...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
5
by: Rod | last post by:
I have a client site where the code below has been working happily for at least four months. The site is using SQL Server 7. The code is ASP.NET Last week an error appeared related to the...
22
by: Kevin Murphy | last post by:
I'm using PG 7.4.3 on Mac OS X. I am disappointed with the performance of queries like 'select foo from bar where baz in (subquery)', or updates like 'update bar set foo = 2 where baz in...
5
by: Anne | last post by:
Hello! Here is the statement in question: --STATEMENT A SELECT * FROM dbo.myTable WHERE colX in (SELECT colX FROM dbo.sourceTable) The problem with Statement A is that 'colX' does not exist...
1
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...

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.