473,405 Members | 2,262 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,405 software developers and data experts.

SQL UPDATE INNER JOIN syntax

91
I have the following syntax for Update Inner Join:

Expand|Select|Wrap|Line Numbers
  1. UPDATE RuleDetail 
  2.  
  3. SET RuleDetail.Function_involved = MasterUpload.Function_involved 
  4.  
  5. FROM RuleDetail
  6.  
  7. INNER JOIN MasterUpload 
  8.  
  9. ON RuleDetail.Rule_description = MasterUpload.Rule_description
However, when I am trying to run it, I am getting an error message -

"Syntax error (missing operator)in query expression 'MasterUpload.Function_involved

FROM RuleDetail

INNER JOIN MasterUpload

ON RuleDetail.Rule_description = MasterUpload.Rule_description'."

Could you please advise where I am going wrong here?

Thanks,
SG
Mar 21 '12 #1

✓ answered by NeoPa

sg2808:
He has for sure mentioned three tables in his SQL - tI, tHL and tblDetail.
The data selected from tI and tHL is Inserted in tblDetail and this is what I had mentioned in the previous post.
Lol. Rabbit was, quite sensibly, referring to the contents of this thread SG. When he said "NeoPa's SQL is different from Mike's only in the table names and field names", he meant that the SQL from posts #2 and #8 were very similar (identical) in structure and syntax.

If he were referring to SQL from other threads, even the one linked in your post #10, he would be clever enough to make that clear in his statement.

Post #16. This is exactly what was required (If I were being extremely picky I would point out that you've only provided one field name for each link, but as it seems obvious that the linking is done between fields of the same names in your case that would be ultra picky even for me).

Try out this SQL and see what you get :
Expand|Select|Wrap|Line Numbers
  1. UPDATE ([MasterData]
  2.        INNER JOIN
  3.        [Process]
  4.     ON MasterData.Detail_Process_Name = Process.Detail_Process_Name)
  5.        INNER JOIN
  6.        [Risk1]
  7.     ON MasterData.Risk_ref_no = Risk1.Risk_ref_no
  8. SET    Process.ProcessID = Risk1.ProcessID

20 19401
MikeTheBike
639 Expert 512MB
Hi

I'm not all together sure but I tyhink it should something lie this
Expand|Select|Wrap|Line Numbers
  1. Update MasterUpload INNER Join RuleDetail
  2. ON RuleDetail.Rule_description = MasterUpload.Rule_description
  3. Set RuleDetail.Function_involved = MasterUpload.Function_involved
??

MTB
Mar 21 '12 #2
sg2808
91
To run the above syntax, I created a copy of the RuleDetail table (to RuleDetail1) to check if it is working properly. I also modified the query (to RuleDetail1).

On hitting Run, I am getting the following error message:

Cannot join on Memo, OLE, or Hyperlink Object (Ruledetail1.Rule_description = MasterUpload.Rule_description).

So, it is still not working.
Mar 21 '12 #3
Rabbit
12,516 Expert Mod 8TB
That's because you can't join on the data types Memo, OLE, or Hyperlink. I assume you're using a Memo data type for your description. You should never use memo unless you actually need that many characters. Use text whenever possible.
Mar 21 '12 #4
sg2808
91
See the SQL code below for an update query using inner join.

Expand|Select|Wrap|Line Numbers
  1. UPDATE Risk1.ProcessID
  2. SET Risk1.ProcessID=Process.ProcessID
  3. From masterdata INNER JOIN Process
  4. ON Masterdata.Detail_process_name=Process.Detail_process_name
I have tried what @Mike the bike had suggested but this is still not working.
I am getting the same error:

Syntax error (missing operator)in query expression 'Process.ProcessID From MasterdataINNER JOIN Process ON
Masterdata.Detail_process_name=Process.Detail_proc ess_name


Please help/advise.
Mar 22 '12 #5
NeoPa
32,556 Expert Mod 16PB
You're not paying attention and progressing in order.

MTB has already fixed one issue for you (If you're unsure of the correct syntax then check it out in Help - Finding Jet SQL Help).

This raised another which Rabbit explained. Your response seems to ignore Rabbit's comment. Furthermore it changes the SQL drastically such that it no longer uses either of the record sources found in post #1. That is irrational behaviour and will result in nothing but grief for you.

I suggest you post something that clarifies :
  1. Which tables/queries you're actually working with.
  2. The field types of each of the fields used in any JOIN statements.

With this information we might be able to proceed.
Mar 22 '12 #6
sg2808
91
Sorry NeoPa but I am not ignoring any of the helps above. As @Rabbit pointed out, I have changed my data so as not to include a Memo field.

Let me start afresh.

I am trying to update a column (ProcessID) in a table(Risk1) from another table (Process) which is having the ProcessID data.

Please note that both the tables (Process and Risk1) have more columns which are already populated.

The data of the above two tables are also in a single master table(Masterdata).

I am trying to pull out the data form the ProcessID field from table-Process (Process.ProcessID) and use the INNER JOIN with the table-Masterdata and update the ProcessID column in table-Risk1 (Risk1.ProcessID).

When I am running the above query, it is giving me an error as mentioned above.

Again, The tables are - Process, Risk1 and Masterdata

The fields are - ProcessID(in tbl Process), ProcessID (in Risk1), Detail_process_name(in Process) and Detail_process_name(in Masterdata)

The process ID fields are Number type and Detail_process_name is text type.

Additional comments - The master table is the source of all data and I know from this table the relationship between the Process and Risk1.
The data is split into two tables - Process and Risk1. The PK of Process is the FK in Risk1. I am trying to populate the FK column in Risk1 table and hence the query.
Mar 23 '12 #7
NeoPa
32,556 Expert Mod 16PB
sg2808:
Sorry NeoPa but I am not ignoring any of the helps above. As @Rabbit pointed out, I have changed my data so as not to include a Memo field.
I'm pleased to hear it, but making such a change without explaining that that is what you've done, is not a helpful way to proceed, as I'm sure you must now realise.

Somewhere along the line you changed the SQL from one invalid syntax to something else (equally invalid), and the format that MTB posted doesn't seem to have registered with you at all.

sg2808:
The data of the above two tables are also in a single master table(Masterdata).
I assume you mean that some sort of copy of the data is contained in [MasterData]? I have no idea why you are complicating matters with this table if what you said about what you're trying to do is correct. It seems to have no bearing on the matter at all and is obviously confusing you badly.

Unfortunately, as your explanation doesn't seem to add up to a consistent whole I will have to guess here which bits I can rely on and which bits are a result of expressing your situation from a confused position. If I get it wrong you may need to clarify your explanation (You appreciate it's hard to give a correct answer when the question itself is so wrong). So, I will assume that [MasterData] is a complete irrelevance and work with :
sg2808:
I am trying to update a column (ProcessID) in a table(Risk1) from another table (Process) which is having the ProcessID data.
Try this :
Expand|Select|Wrap|Line Numbers
  1. UPDATE [Risk1] INNER JOIN [Process]
  2. ON     Risk1.Detail_process_name=Process.Detail_process_name
  3. SET    Risk1.ProcessID=Process.ProcessID
As I say, if that isn't your problem then we need something clear from you that makes sense.
Mar 23 '12 #8
sg2808
91
Thanks NeoPa.

The problem here is that the Risk1 table do not include the Detail_process_name field. Infact, there is no common field between the two tables (Process and Risk1).

This field (Detail_process_name) is in the Masterdata table and Process table. I was trying to use these tables to update the Risk1 field (it may not be the right way).

The Masterdata table (that has all the fields which are in Process and Risk1 tables) is not relevant for my database but I have this table in the database to help me to update the FK field (ProcessID) in Risk1.

I may be wrong in my thinking but cant think of any other approach. May be you can help me with the approach or the syntax.
Mar 23 '12 #9
sg2808
91
NeoPa,

For further clarification, I am continuing here as there is link between the posts.

I was trying to use the logic as per your solution (see Post#21) for the question I had on the link below.

http://bytes.com/topic/access/answer...er-import-data

However, in this case, I am trying to update a specific column only.
Mar 23 '12 #10
Rabbit
12,516 Expert Mod 8TB
I too am confused as to why you're keeping two copies of the same data.

This is the first I'm hearing about three tables. You never mentioned that originally. Also, your table names and field names keep changing from each attempt. It's now at the point where I have no idea which table and field name is correct.

If we make the assumption that post 7 is actually what you have, and you have three tables to join together, then you have to join those three tables together.

You say that you're following Mike's example but all your SQL attempts look nothing like his example. You need to take a closer look at his example.
Mar 23 '12 #11
NeoPa
32,556 Expert Mod 16PB
It seems you have a problem explaining your questions very clearly (The other thread has that same problem too). Let's see what we can do to help with that then (as this is still like trying to swim through treacle).

Please post, in here, all the fields that you think are relevant from all the tables that you think are, or should be, involved in this problem. Please make clear the actual names of each table and field (Using [] around actual names makes it clear you're referring to actual object names). For each field, please identify which fields in any of the other relevant tables it can be used to link from or to.

Identify also, which field is to be updated, and which field the data is to be taken from. If you do all this in this single post then finding relevant info won't be such a chore. I will continue on the basis that this new post is absolutely correct and not the information from any previous posts. It is very important therefore, that you get this right first time. If not, we go back to a situation where there is much information in many posts and knowing what we can rely on and what we cannot is a struggle every time we post.
Mar 23 '12 #12
sg2808
91
Yes, post 7 is actually what I have.

I do not want to keep the Masterdata table, I would be deleting it. I have brought it in to help me use the INNER JOIN between table-Process and table-Masterdata.

NeoPa's SQL is definitly different, I am just trying to use the logic (as his SQL also involves 3 tables). His SQL is Inserting the data in a 3rd table using inner join in other two tables.

Similarly, I am tying is to Update the Process ID field in Risk1 table using INNER JOIN on Process and Masterdata table.

My approach or the problem could be totally wrong and I need something more to be done but this is where I need your expert opinion.
Mar 23 '12 #13
Rabbit
12,516 Expert Mod 8TB
NeoPa's SQL is different from Mike's only in the table names and field names. The logic remained the same. Neo does not use three tables. In essence, Neo's SQL is the same as Mike's.
Mar 23 '12 #14
NeoPa
32,556 Expert Mod 16PB
sg2808:
I need something more to be done but this is where I need your expert opinion.
Not until you've responded intelligently to post #12. Without that information (which, as I'm sure you're beginning to understand, should have been included in the first post with the question) we are in no position to understand what you are continuing to talk about.
Mar 23 '12 #15
sg2808
91
The tables are - [Process], [Risk1] and [Masterdata]

The fields (format is [tablename].[fieldname]) relevant for this discussion, I think, are:

[Process].[ProcessID]- PK
[Process].[Detail_process_name]
[Risk1].[RiskID]-PK
[Risk1].[ProcessID]-FK
[Risk1].[Risk_ref_no]
[Masterdata].[MasterdataID]-PK
[Masterdata].[Detail_process_name]
[Masterdata].[Risk_ref_no]

The data under [Process].[ProcessID] needs to be taken out.
The field [Risk1].[ProcessID] needs to be updated with the above data.

Table[Masterdata] can be linked to table[Process] on field[Detail_process_name].

Table[Masterdata] can be linked to table[Risk1] on field [Risk_ref_no].
Mar 23 '12 #16
sg2808
91
@Rabbit - That was my first stab at SQL and NeoPa's SQL is printed and pinned on my desk for easy reference and inspiration :-)

He has for sure mentioned three tables in his SQL - tI, tHL and tblDetail.
The data selected from tI and tHL is Inserted in tblDetail and this is what I had mentioned in the previous post.
Mar 23 '12 #17
NeoPa
32,556 Expert Mod 16PB
sg2808:
He has for sure mentioned three tables in his SQL - tI, tHL and tblDetail.
The data selected from tI and tHL is Inserted in tblDetail and this is what I had mentioned in the previous post.
Lol. Rabbit was, quite sensibly, referring to the contents of this thread SG. When he said "NeoPa's SQL is different from Mike's only in the table names and field names", he meant that the SQL from posts #2 and #8 were very similar (identical) in structure and syntax.

If he were referring to SQL from other threads, even the one linked in your post #10, he would be clever enough to make that clear in his statement.

Post #16. This is exactly what was required (If I were being extremely picky I would point out that you've only provided one field name for each link, but as it seems obvious that the linking is done between fields of the same names in your case that would be ultra picky even for me).

Try out this SQL and see what you get :
Expand|Select|Wrap|Line Numbers
  1. UPDATE ([MasterData]
  2.        INNER JOIN
  3.        [Process]
  4.     ON MasterData.Detail_Process_Name = Process.Detail_Process_Name)
  5.        INNER JOIN
  6.        [Risk1]
  7.     ON MasterData.Risk_ref_no = Risk1.Risk_ref_no
  8. SET    Process.ProcessID = Risk1.ProcessID
Mar 23 '12 #18
sg2808
91
Yep, realized after posting that :-), never mind.
Mar 24 '12 #19
sg2808
91
Hi NeoPa,

When I tried to run with your SQL, I get a message as - "Cannot update Process.ProcessID; field not updateable. I guess, because Process.ProcessID field is a autonumber field.

Looking at the SQL above, I just want to cross check that the last line, should it be written as (because I would like to update the Risk1.ProcessID field):

SET Risk1.ProcessID = Process.ProcessID

When I run the SQL with the change as above, I get this message - "You are about to update 0 row(s)....".
Mar 26 '12 #20
NeoPa
32,556 Expert Mod 16PB
sg2808:
I guess, because Process.ProcessID field is a autonumber field.
You can believe it. If, as you say, Process.ProcessID is an AutoNumber field, then it certainly could not be updated.

sg2808:
When I run the SQL with the change as above, I get this message - "You are about to update 0 row(s)....".
The SQL is fine, but I suspect there is something else awry with what you've told us. Recent posts have started to indicate a consistent situation that makes sense. Unfortunately, this indicates it's not a completely accurate representation of your real position. SOmething is not right, but I'm afraid I can't tell you what that is as I don't have the information from you with which to determine what that might be. All I can say is that there appear to be no records selected which match the criteria specified. Hopefully, that will be enough to get you looking in the right direction at least.
Mar 26 '12 #21

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

Similar topics

0
by: Richard | last post by:
Hi, I work on a VB6 software using ADO to connect to Oracle 9.2i. When I create a recordset based on a query containing a "inner join" clause (sql server syntax, the software connects also...
3
by: indabert | last post by:
Hello, I have two tables (table1 and table2). I want to set a flag in table1 for each common row with table2. I use the following syntax UPDATE table1 SET flag='Y' from table1 INNER JOIN table2...
4
by: meyvn77 | last post by:
Im using an ADP to connect to a SQL Sqever DB. In access it was really easy to say Inner join on table1 and table2 and update columnA from table1 with columnC from table2 where table1.key =...
10
by: deko | last post by:
I've tried each of the below, but no luck. UPDATE tblEntity As tbl INNER JOIN search3220 As qry ON tbl.Entity_ID = qry.Entity_ID SET tbl.Cat_ID = 289; UPDATE tblEntity INNER JOIN search3220 ON...
6
by: dmonroe | last post by:
hi group -- Im having a nested inner join problem with an Access SQl statement/Query design. Im running the query from ASP and not usng the access interface at all. Here's the tables: ...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
12
by: info | last post by:
The following query works fine in access and does exactly what I want it to do however I get a syntax error when I port it over to SQL Server 2000. ------------- UPDATE OrdersProducts INNER...
12
by: Chamnap | last post by:
Hello, everyone I have one question about the standard join and inner join, which one is faster and more reliable? Can you recommend me to use? Please, explain me... Thanks Chamnap
11
by: YZXIA | last post by:
Is there any difference between explicit inner join and implicit inner join Example of an explicit inner join: SELECT * FROM employee INNER JOIN department ON employee.DepartmentID =...
1
maxamis4
by: maxamis4 | last post by:
I have the following query that I am trying to carry over from ms access to ms sql server. I keep getting a msg 156, level 15, state 1, line 2 Incorrect syntax near the keyword "INNER". it works...
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...
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
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
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...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.