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

Select Query, joined field in 1 table has wildcard characters

I'm running Access 2000 on Windows XP.

I have a simple select query, with two tables joined at the "Account" field. The account field has 5 characters of text in both tables

Table A is a reference table with categories for the accounts.
Table B is the main transactions table with actual activity by account.

Table A's records have the account field utilizing wildcard characters, ex. "111##", to capture ranges of accounts.
Table B's records have the account field with the full 5 characters, ie. "11123".

My query returns no results.

I didn't want to have individual records for each and every account in Table A, which is why I used the wildcard characters. Is this not possible, or should I be using another approach?



Any help will be greatly appreciated.
Thanks!
Nov 13 '06 #1
9 3844
willakawill
1,646 1GB
I'm running Access 2000 on Windows XP.

I have a simple select query, with two tables joined at the "Account" field. The account field has 5 characters of text in both tables

Table A is a reference table with categories for the accounts.
Table B is the main transactions table with actual activity by account.

Table A's records have the account field utilizing wildcard characters, ex. "111##", to capture ranges of accounts.
Table B's records have the account field with the full 5 characters, ie. "11123".

My query returns no results.

I didn't want to have individual records for each and every account in Table A, which is why I used the wildcard characters. Is this not possible, or should I be using another approach?



Any help will be greatly appreciated.
Thanks!
Hi. Table A is a lookup table which should have a UID (unique identifier) which will normally be the autonumber set by the database. This will be the primary key (PK) for this table. The next field will be the data which is your account info.

Table B will have a foreign key (FK) which you will link to the UID of table A

Would you please submit the query that does not work?
Thanks
Nov 13 '06 #2
Hi. Table A is a lookup table which should have a UID (unique identifier) which will normally be the autonumber set by the database. This will be the primary key (PK) for this table. The next field will be the data which is your account info.

Table B will have a foreign key (FK) which you will link to the UID of table A

Would you please submit the query that does not work?
Thanks

Here's the sql view of my query, although I'm using the design-view to construct the query.

SELECT [Table A].descp0, Sum([Table B].[trans amt]) AS [SumOftrans amt]
FROM [Table B] LEFT JOIN [Table A] ON [Table B].Account = [Table A].Account
GROUP BY [Table A].descp0;

Not sure how I'd utilize your suggested approach with the FK?
Nov 13 '06 #3
NeoPa
32,556 Expert Mod 16PB
I often recommend using the design approach to develop a query.
Unfortunately, that's not very good for communicating the details of that query.
Or should I rather say that, fortunately, the SQL view is!
Nov 13 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
I'm running Access 2000 on Windows XP.

I have a simple select query, with two tables joined at the "Account" field. The account field has 5 characters of text in both tables

Table A is a reference table with categories for the accounts.
Table B is the main transactions table with actual activity by account.

Table A's records have the account field utilizing wildcard characters, ex. "111##", to capture ranges of accounts.
Table B's records have the account field with the full 5 characters, ie. "11123".

My query returns no results.
You can't join two tables on a field that is not the same. In other words you cannot join on a like statement.


I didn't want to have individual records for each and every account in Table A, which is why I used the wildcard characters. Is this not possible, or should I be using another approach?
Create another table with a list of all accounts and a foreign key reference to the primary key of Table A. Then remove the field from Table A altogether.

You can now join table A and Table B together using the new table.

Table A will join to new table on the PK to FK reference and Table B will join to the new table on the Account ref.
Nov 13 '06 #5
thanks for your help, I'll give it a try
Nov 16 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
thanks for your help, I'll give it a try
You're welcome.

If you've any questions, please let us know and check out the 'Links to useful Sites' thread at the top (or nearly) of the Access Forum.
Nov 16 '06 #7
nico5038
3,080 Expert 2GB
Hi Romanko,

You have a design issue at hand. Can you explain why you use "grouped" accounts ?

Normally you would record different information for a higher level of account numbers. This can be modelled best by having a "tblSuperAccount" with the overall information. Then you can relate the "tblSubAccount" (or e.g. "tblDetailAccount) by the unique key of the tblSuperAccount.
Using "fixed" ranges is normally regarded as asking for trouble. Just imagine that the DetailAccount grows to a number above 999....

Why do you want to suppress data for all accounts ?

Nic;o)
Nov 16 '06 #8
I took the fixed ranges approach because there are something like 90,000 account numbers (they are accounting expense accounts). I need to keep them categorised, but new accounts are added and old ones deleted regularly, however the numbering always follow set rules: ex. accounts 31000 to 31999 are categorized as office supplies. So I just wanted to setup one record in the table with the account field set at 31### to capture this range, reducing how much time I'd spend maintaining this table, and the size of the table.
Nov 17 '06 #9
nico5038
3,080 Expert 2GB
OK, then the "normalized" way is to have a tblCategory for the fields needed on this "level".
In the tblAccount you should use 2 fields:
1) CategoryID
2) AccountSequenceNo
Thus you can relate the tables easily in a JOIN and for showing the needed full account number use:
Select CategoryID & AccountSequenceNo as AccountNo, ...

Getting the idea ?

Nic;o)
Nov 17 '06 #10

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

Similar topics

2
by: skidvd | last post by:
Hello: I have just recently converted to using the InnoDB table type so that I can enforce FOREIGN key constraints. I have been using MyISAM tables (accessed via JDBC) successfully for some...
7
by: CharlesEF | last post by:
Hi All, I have run into another problem that is eating my lunch. Should be simple but I am having one heck of a time. Please look at this SELECT statement: SELECT FROM States WHERE ] =...
2
by: allyn44 | last post by:
Hello--I have 2 tables (illness,event) that a need to query and create a recordset The key fields are personId and description (text field) in each table. I also have other needed fields in the...
9
by: Kelvin | last post by:
Okay so this is baking my noodle. I want to select all the attritbutes/fields from a table but then to excluded any row in which a single attributes data has been duplicated. I.E. Here's my...
4
by: Ben | last post by:
I believe I am missunderstanding how subqueries work. I simple subquery works fine but when I wish do compare 2 or more fields at once I don't get the results I wish. Table A...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
2
by: jacoballen | last post by:
I have a query that combines the results of three related tables. The memo fields are truncated to 255 characters, but I need all the information in them. I'm aware that removing code such as...
4
by: JohnH | last post by:
I have a simple task to perform that I cannot seem to figure out. I have two tables: OR_CUs OR_CEOs They share (can be joined on) a field called , which is just the name of the CU. All I...
1
by: racquetballer | last post by:
I need to to an update query that involves three tables: table Dealer needs to be updated with data from table Personnel and table Title. Dealer is joined to Personnel where Dealer.Dealer_Code =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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...

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.