I have a table (Table A) that includes every number that's been dialed in our call center. I have another table (Table B) that has account numbers and three different phone fields for each account.
What I initially tried was to left join the Dialed Number column from Table A to all three phone number columns in Table B. This produces no results. If I only join Dialed Number to Phone Number 1 (for example), I get results, however, if the agent dialed one of the other two numbers, it's not going to show up.
tblListeners ----------- ID (PK) FirstName LastName etc
tblReference ------------ ID (PK) ListenerID ReferenceTypeID (FK) ReferenceDate etc
(Btw I am aware of the unconventional naming of the PKs but I'm running the B/E on SharePoint so I have no choice!)
So listeners have to periodically do a reference. What i want is a query that tracks if listeners either have not done a reference EVER or haven't done one for a while, but broken down by the FK in tblReference.
Here is my reasonably simple SQL so far:
SELECT tblListeners.ID AS ListenerID, tblListeners.FirstName, tblListeners.LastName, tblReference.ReferenceTypeID, tblReference.ReferenceDate FROM tblListeners LEFT JOIN tblReference ON tblListeners.ID = tblReference.ListenerID WHERE (((tblReference.ListenerID) Is Null) AND ((tblReference.ReferenceDate) Is Null)) OR (((tblReference.ReferenceDate)<DateAdd("m",-6,Date()))) ORDER BY tblListeners.FirstName, tblListeners.LastName;
In the current query the results ignore the FK so the so a listener will be missing if they have done one type of reference - i want them to be there (or not be there) for each type of reference. Hope that makes sense!
Now i know people may suggest a crosstab for this but: a) I don't get on with them and wouldn't know how to implement it and b) this will need to be in a report and I don't want to venture down the 'dynamic crosstab report' path!
All retailers have at least one distributor BUT a retailer may or may not have ordered any products.
I have created my form but the query linked to the form is having some trouble. It is only selecting those records that have ordered products. For example, if I query a retailer name only and it does not have any ordered products, it will not display. Is there a problem with the table joins? The SQL for the query is displayed here:
Not sure if this is possible? I have a column called Issues and another column I want to call ShortIssues and I basically want ShortIssues to be Left(Issues,50) so that its just 50 characters long of column Issues.
Hello, I have the following code for a multiple join:
INSERT INTO [AppendAllFields]SELECT [TreatyList].[Treaty] AS [Treaty],[MLAC 42 Treaty Xref ER].[tai treaty] AS [TreatyType],[txn 01/04].[Policy_Number] (and more other fields from [txn 01/04] table) FROM [txn 01/04] INNER JOIN [MLAC 42 Treaty Xref ER] ON TRIM([txn 01/04].[Policy_Number]) = TRIM([MLAC 42 Treaty Xref ER].[Polnum]) INNER JOIN [TreatyList] ON TRIM([MLAC 42 Treaty Xref ER].[tai treaty]) = TRIM([TreatyList].[TreatyNo]);
Basically, the txn 01/04 table has a corresponding Polnum field in the MLAC 42 table, and MLAC 42 table has a tai treaty field, which corresponds to TreatyNo in TreatyList table.
However, when I tried to run this, I got an Syntax error.
I am trying to set up a file compare process. I load the two files into two "matching" tables (there is a key field). I have a series of queries which find any differences in the various fields and displays them. My problem is that one field (Field4 - a tran code) is coded 1,2,3 in one file and A,B,C in the other. I have set up a third translation table with two columns, each row showing the matching codes (1/A, 2/B, 3/C, etc). I want to find corresponding rows in FILE1 and FILE2 (matched on KEY) where tran codes (Field4) do not match (ie a "1" in File1 but NOT a "A" in FILE2).
I have not been able to get the two inner joins to work. Can some one help.
This is my last attempt:
FILE1: KEY-Field1-Field2-Field3-Field4 FILE2: KEY-Field1-Field2-Field3-Field4 (Field4 is the code that needs to be translated)
FILE3/numeric/alphabetic 1 A 2 B 3 C 4 D
SELECT FILE1.KEY,FILE1.Field4, FILE2.Field4 FROM FILE1 INNER JOIN FILE2 ON FILE1.key = FILE2.key INNER JOIN [FILE3] ON (FILE1.Field4 = FILE3.alphabetic) WHERE FILE2.Field4 <> FILE3.numeric.
Initially the query below used Inner Joins, however that limits my list, when i want to see ALL elements from the MasterTable no matter what, thus my inner joins became left and right joins as follows.
Simple Query: Query1
SELECT MasterTable.Station, MasterStable.Description, MasterTable.Area, AreaTable.Percent, GangTable.GangID, GangTable.Speed FROM (AreaTable RIGHT JOIN MasterTable ON AreaTable.AreaID = MasterTable.Area_ID) LEFT JOIN GangTable ON AreaTable.AreaID = GangTable.Area_ID;
This should simply display All Records in MasterTable, (Multiple Times if Necessary) listing all the elements of AreaTable that are Linked to the MasterTable, and all elements from GangTable that are linked to AreaTable. It does this, and displays them nicely. But I can't edit the fields. I get the result:
1 | Station One | Area 1 | 45% | 204 | 1000 1 | Station One | Area 1 | 45% | 304 | 500 1 | Station One | Area 1 | 45% | 404 | 750 2 | Station Two | Area 1 | 45% | 204 | 1000 2 | Station Two | Area 1 | 45% | 304 | 500 2 | Station Two | Area 1 | 45% | 404 | 750 3 | Station Three | Area 2 | 75% | 254 | 800 3 | Station Three | Area 2 | 75% | 354 | 600 3 | Station Three | Area 2 | 75% | 454 | 700
So you can see that Area 1 has multiple Gangs (204,304,404) and Multiple Stations (1,2). If you do a simple set up like this, you'll find that you can't change the Description field (Rename "Station One" to "Hello World"). It just doesn't work, no matter which way I've tried, I can't seem to make a Query that presents all the information from MasterTable and All the Information IN AreaTable and All the Information in GangTable which will allow me to also edit the fields.
Any Help would be most appreciative, I'm tearing my hair out on this one. Thanks, Jaeden "Sifo Dyas" al'Raec Ruiner
ps - It just seems that with Junction Tables and all the many to many relationship designs I have tried, you'd be able to change the non-related fields. I understand that you can't change the "ID" fields, but the others should be editable.
My query references 2 related tables: one for persons (PERS) and one for telephone/fax numbers and email addresses (CONT, for Contacts). The relevant fields are:
The foreign key come_id refers to a table for contact methods (COME), either "Phone (Home)", "Phone (Work)", "Mobile", "Fax" or "Email".
Now i want to list all persons with their home phone number and email address, also if they don't have one. It seems to be impossible to get it ... I will explain what happens. Lets start simple: first list all persons with their home phone number (come_id = 1): SELECT PERS.pers_forename, PERS.pers_surname, CONT.cont_number AS Phone FROM PERS LEFT JOIN CONT ON PERS.pers_id = CONT.pers_id WHERE (((IIf(IsNull([come_id]),1,[come_id]))=1)); This works fine. The IIf expression is necessary since we are dealing with an outer join: not all persons have a home phone number. If we would simply put "WHERE come_id = 1" then the query produces only the persons that have a home phone number.
But now i also want to see the email address (come_id = 5): SELECT PERS.pers_forename, PERS.pers_surname, CONT.cont_number AS Phone, CONT_1.cont_number AS Email FROM CONT AS CONT_1 RIGHT JOIN (PERS LEFT JOIN CONT ON PERS.pers_id = CONT.pers_id) ON CONT_1.pers_id = PERS.pers_id WHERE (((IIf(IsNull([cont].[come_id]),1,[cont].[come_id]))=1) AND ((IIf(IsNull([cont_1].[come_id]),5,[cont_1].[come_id]))=5)); It seems perfectly logical: i added a second alias CONT_1 for the email address. Since this is also optional we have a second outer join, and the WHERE condition should also use an IIf expression. The result is not correct though: the resulting recordset shows only the persons that have both a home phone number and an email addres or neither! I have a lot of experience with SQL and queries, but i know i am not infallible. Nevertheless i am quite convinced that i should get all the persons: those that have a home phone number or an email address, or both or neither ... I hope that someone of you can explain this.
I have this query in design view and in an asp page and it works fine:
SELECT dbo_feedback.*, dbo_origin.originName, dbo_product.prodname, dbo_category.catName FROM dbo_product INNER JOIN (dbo_origin INNER JOIN ((dbo_feedback INNER JOIN (dbo_category INNER JOIN links_cat ON dbo_category.catID = links_cat.CatID) ON dbo_feedback.id = links_cat.FeedbackID) INNER JOIN links_product ON dbo_feedback.id = links_product.FeedbackID) ON dbo_origin.originID = dbo_feedback.origin) ON dbo_product.prodID = links_product.ProductID;
BUT, I want to return all feedback entries, even if they have no matching Product or Category. :confused: When I change the inner joins to outer joins I get a syntax error in the browser window. I changed the join type in the relationship diagram in Access and tried to recreate this in query designer, but Access says the statement cannot be executed because of ambiguous outer joins.
FYI, one feedback can have many products, many categories, and only one origin. I have the joins correct and enforced.
Hi. I have a question I'm hoping someone can help me with. I would like to take data from multiple columns and put the data into one column. Additionally, I do not want to exclude any data (union all) and I would like to group the resulting union by another field. For example:
So far I'm using the following SQL. What do I need to add or change to get my desired result of grouping the unioned depths by the 'sample event' field?
I appreciate any help anyone may have to offer. Thank you.
SELECT Depth1 AS Depths FROM Depth_Velocity_Substrate_Correct Union all SELECT Depth2 FROM Depth_Velocity_Substrate_Correct Union all SELECT Depth3 FROM Depth_Velocity_Substrate_Correct Union all SELECT Depth4 FROM Depth_Velocity_Substrate_Correct Union all SELECT Depth5 FROM Depth_Velocity_Substrate_Correct
I just restructured my DB and I was wondering if anyone can give me some advice on whether or not my joins/relations are correct. I left some joins/relations out because I wasn't sure what relation I should use.
I have an access database where i allow users to review coffeeshops they have visited. I have multiple entries they can enter such as rate_weed, rate_service, rate_atmosphere, rate_price.
I would like to be able to have an "overall" rating which averages these four columns together. Is this possible??
I have parent-child one to many data in one pair of relationships, and now I've been asked to see be able to find out what matches a defined regimen; each is also defined in a parent-child relationship.
Best is to show sample data. I'm going to show them as two tables, but the "Components" are actually in a parent-child relationship, e.g.,
PersonList -= Meds Regimen -= Meds as well
Note that PersonList and Regimen do not really have any relation; we just want to see if things are being done one of the ways they are "supposed" to be done, without a slow manual check. It's worked as set up for reports, and I really don't want to change everything to a big long list of fields, one field per med for a lot of reasons (not least of which is that is denormalizing)
Quy 1 Result: PersList T1Component Andrew Med 1 Andrew Med 2 Brett Med 1 Brett Med 3 Brett Med 4 Charles Med 2 Duane Med 1 Duane Med 4
Quy 2 Result Regimen T2Component Goody1 Med 1 Goody1 Med 3 Goody1 Med 4 Goody2 Med 1 Goody2 Med 2
I'd like to be able to do two queries - one that are "OK" one that are not. Don't need to replicate the med list, just the regimen if matching..
"Good" would return Person Regimen Andrew Goody2 (he has med 1, 3, and 4) Brett Goody1 (he has med 1 and 2)
"Bad" would return Person Charles Duane
What they "almost match" does not matter; it tells people which ones we need to check into a bit more.
I am trying to run below to update multiple records in the same column and get error message saying characters found after end of SQL statement. I tried to remove ; but then get a syntax error.
Code: UPDATE [tblMonthly] SET [Date] = #20130701# where [File] = 'A'; UPDATE [tblMonthly] SET [Date] = #20130801# where [File] = 'B';
I am working with other data that has been created by someone else.
There are a number of columns with the same information in (a serial number). What I need to do is get this into one long column so that I can run other queries from it.
So far I have tried using this SQL:
SELECT A1-TX1 POWER AMPLIFIER 1 FROM SM_Cabinet_T UNION ALL SELECT A1-TX1 POWER AMPLIFIER 2 FROM SM_Cabinet_T
[Code] .....
But it is not working - Is it to do with the field names or am I entering something incorrectly?
I'm not familiar with listbox yet and i want to filter my form using it.
I have two separate listboxes which display "category" & "type" data from the same table.
Here is the situation i wanted for my listbox.
1. Select one data from "category" listbox. 2. Then it will automatically filter data from "type" listbox or it will list all related "type" data corresponding to "category" data. 3. Then select one data from "type" listbox and it will filter all related data on the form/sub-form.
Is it possible to do that way? Can i do it on multicolumn listbox instead of using 2 listbox?
Is there a way to have multiple validation rules in one column in a table. In one column, I need the values to be in all lower case and the first three characters need to be three letters.
I have a multiple column combo box on my form, that is correctly populating. When I make a selection, it displays the result from the first column. Bound column seems correct, as my table is being populated correctly.
1 - Can I display the values from both columns after the selection has been made?
2 - If not, can I choose to display the second column (not the first) after the user has made a selection?
I have a column that has a bunch of keywords they are separated by comma... so for each row of that column it will have a few different keywords example: lake superior, river, mountain, lake wollongong
I know its a bit of a nono with databases to have columns with comma separated text.. well so i read somewhere anyway but the document i have been handed to work has hundreds of rows in this column with up to 14 keyword entries.
I have a form that searches through Item's names based on 2 keyword boxes.
Here's the criteria in my query:
Is Null Or Like "*" & [Forms]![frmItemView]![SearchPhrase1] & "*" And Like "*" & [Forms]![frmItemView]![SearchPhrase2] & "*"
This will show all records when both keywords are blank, and filter records using the 2 keywords otherwise.
I have a form with two text boxes and have set the correct values as outlined in Evans post. I then have the query set to run via a button. I run it but it will only give back records for the entry i have put in the 1st text box. This would work well for me otherwise... mine is like this:
Is NULL or Like "*" & [Forms]![Searchtable]![Key1] & "*" And Like "*" & [Forms]![Searchtable]![Key2] & "*"
Searchtable being my search form key1 being my first text box entry key2 being my second text box entry
I'm working with a table of bird survival data I am trying to summarize in a query. I've got a bit of a roundabout way to achieve my goal, but I'm curious if there is a simpler approach.
Background : In my table, each row represents a day I check a given nest and includes a [Nest ID] (not unique, multiple visits to each nest), a [visit ID] (auto numbered, so it's a unique value for each visit at each nest), the calendar day I visited a nest [Date], and [Survive] (1 or 0) depending on whether a nest survived or failed.
I'm trying to convert this detailed table into one that is more concise. Instead of each visit to a nest being a row, each nest becomes a row with 4 fields: The Nest ID, the minimum date (the day I found a nest), the last day a nest was checked (Max[Date]), and the last day a nest was checked alive (essentially max date where survival=1).
My current solution is to run 3 separate queries. The first queries the max date where survival=1, the second queries the max and min dates regardless of any other criteria, and the third brings both queries together.
I am curious if there is a way to create the same final product in a single query rather than doing multiple ones as I have done?