Error MySQL Update Inner Join tables query

0 votes

I have no idea what the problem is. Using MySQL 5.0 I get a compile error when attempting to run the following MySQL update query:

UPDATE  b
SET b.mapx = g.latitude,
    b.mapy = g.longitude
FROM business AS b
INNER JOIN business_geocode g ON b.business_id = g.business_id
WHERE (b.mapx = '' OR b.mapx = 0) AND
      g.latitude > 0

All the field names are correct. Any thoughts?

Aug 19, 2020 in PHP by kartik
• 37,520 points
2,073 views

1 answer to this question.

0 votes

Hello @kartik,

Try this:

UPDATE business AS b
INNER JOIN business_geocode AS g ON b.business_id = g.business_id
SET b.mapx = g.latitude,
  b.mapy = g.longitude
WHERE  (b.mapx = '' or b.mapx = 0) and
  g.latitude > 0

Hope it helps!!
Thank you!

answered Aug 19, 2020 by Niroj
• 82,840 points

Related Questions In PHP

0 votes
0 answers

Join two MySQL tables with PHP

I have created two pages and two ...READ MORE

Jul 30, 2022 in PHP by Kithuzzz
• 38,000 points
1,182 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
10,540 views
0 votes
1 answer

Error:Lost connection to MySQL server at 'reading initial communication packet', system?

Hello, You have to follow the below steps: bind-address ...READ MORE

answered Apr 9, 2020 in PHP by Niroj
• 82,840 points
21,021 views
0 votes
1 answer

How can I do an UPDATE statement with JOIN in SQL Server?

Hello @kartik, This should work in SQL Server: update ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,840 points
975 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,012 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
2,995 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,918 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,696 views
0 votes
1 answer

Error:Unknown column in 'field list' error on MySQL Update query

Hello @kartik, Enclose any string to be passed ...READ MORE

answered Aug 20, 2020 in PHP by Niroj
• 82,840 points
13,759 views
0 votes
1 answer

MySQL - UPDATE multiple rows with different values in one query

Hello @kartik You can use a CASE statement to handle ...READ MORE

answered Jun 1, 2020 in PHP by Niroj
• 82,840 points
33,828 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP