UPDATE COmmand post comparing 2 columns in 2 mysql tables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting UPDATE COmmand post comparing 2 columns in 2 mysql tables
# 1  
Old 06-09-2015
UPDATE COmmand post comparing 2 columns in 2 mysql tables

my queryis :

select distinct m.name, item_count, item from master m join client p on m.name=p.name where item_count = 1 and item > 1;
[/CODE]But how should I update them?

i used update statetment :

Code:
Update from client Set item =1  where m.name=p.name and item_count=1 AND item>1

Is this wrong?

Last edited by siya@; 06-19-2015 at 04:18 AM..
# 2  
Old 06-11-2015
So I used this to find the entries:
Code:
select distinct m.name, item_count, item from master m join client p on m.name=p.name where item_count = 1 and item > 1;

But how should I update them?

Code:
Update from client Set item =1  where m.name=p.name and item_count=1 AND item>1

Is this wrong?
Moderator's Comments:
Mod Comment Typing the string Code: in front of some text is not the same as putting some text in CODE tags as in: [CODE]some text[/CODE]. Please use CODE tags when displaying sample input, sample output, and sample code segments.

Last edited by siya@; 06-19-2015 at 04:20 AM.. Reason: Add CODE tags,
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Comparing two tables

I have defined a set of global variables at the beginning of my script as below: #ideal values export ITEM1=SUCCESS export ITEM2=FAILURE export ITEM3=UNAVAILABLE export ITEM5=FAILURE export ITEM6=SUCCESS now I have a shell script function which returns a value in below format. ITEM1... (1 Reply)
Discussion started by: ctrld
1 Replies

2. Shell Programming and Scripting

Show only new and removed records by comparing to MySQL tables

Hello all; I have been really frustrated with finding the correct perl code (and MySql statements) to accomplish what I thought was straight forward...I have tested I don't know how many different codes\suggestions I found on the net without any success...but anyhow let me explain my plight and... (0 Replies)
Discussion started by: gvolpini
0 Replies

3. Programming

MySQL join four tables!

Hello; I want merge four MySQL tables to get the intersection that have a common field for all of them. Join two tables is fine to me, but my this case is different from common situations and there are not very many discussions about it. Can anybody give me some idea? Thanks a lot! Here is part... (8 Replies)
Discussion started by: yifangt
8 Replies

4. Web Development

mysql query for multiple columns from multiple tables in a DB

Say I have two tables like below.. status HId sName dName StartTime EndTime 1 E E 9:10 10:10 2 E F 9:15 10:15 3 G H 9:17 10:00 logic Id devName capacity free Line 1 E 123 34 1 2 E 345 ... (3 Replies)
Discussion started by: ilan
3 Replies

5. Shell Programming and Scripting

Shell script for comparing data of tables

Hi, I have two databases with same tables on different servers.I need to check the data content in each table and if something is missing, should print that. I have a tool which takes the snapshot the table structure,index so on and compares with the other server tables snapshot. Now i need... (1 Reply)
Discussion started by: nessj
1 Replies

6. Shell Programming and Scripting

comparing two tables

I am comparing two table structure in different databases,Put into 2 txt files , when comparing if column sequnce and data type is not matching ,it has to display that info else Table structure is ok. wrote shell script ,its not working .I am getting "Table structure is not ok" even if both... (1 Reply)
Discussion started by: akil
1 Replies

7. Shell Programming and Scripting

Converting tables of row data into columns of tables

I am trying to transpose tables listed in the format into format. Any help would be greatly appreciated. Input: test_data_1 1 2 90% 4 3 91% 5 4 90% 6 5 90% 9 6 90% test_data_2 3 5 92% 5 4 92% 7 3 93% 9 2 92% 1 1 92% ... Output:... (7 Replies)
Discussion started by: justthisguy
7 Replies
Login or Register to Ask a Question