473,809 Members | 2,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MySQL : Looping query

9 New Member
I am trying to insert records into a mastertable. The first field is auto-incrementing and therefore I am unable to insert all records at the same time. I have create the following code to insert one record in at a time.

insert into `mastertable3`
select ' ', 0301_2500.ssn, 0301_2500.vsssn , 0301_2500.name_ ind, 0301_2500.pay_g r_aa
from time_period, Mastertable3 right join 0301_2500 on mastertable3.ss n = 0301_2500.SSN
where (((if(mastertable3.s sn=0301_2500.ss n, 0, 1))=1))
limit 1

I am trying to create a loop to have this repeat continuously until the table 0301_2500 is exhausted, then switch to table 0302_2500, and etc...

Any ideas?
Jul 10 '07 #1
3 2257
mwasif
802 Recognized Expert Contributor
Mention the column names in INSERT statement except auto increment field e.g.

Expand|Select|Wrap|Line Numbers
  1. insert into `mastertable3` (field1,field2,field3,field4)
  2. select 0301_2500.ssn, 0301_2500.vsssn, 0301_2500.name_ind, 0301_2500.pay_gr_aa
  3. etc..
Jul 10 '07 #2
DougieC
9 New Member
Didnt work. I believe the problem is that it can not generate multiple auto_incremente d numbers simultaneously. I would like to figure out how to do this with looping. Any links or walk throughs on looping would be helpful.
Jul 10 '07 #3
r035198x
13,262 MVP
Didnt work. ...
What had you tried and what happened when you tried it?
Jul 10 '07 #4

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

Similar topics

3
7564
by: Benjamin Dickgießer | last post by:
Hi, I want to create a sql query but don't know if this is possible with mysql. The Query should do the following: Select all db entries from table in which entry a is smaller than the number (count) of all db entries with criteria x from another table. Thx for your help! Benjamin Dickgießer
13
5562
by: aaron | last post by:
I have a question about (i think) joining. If I have a table in a database that has this info: key - name - favorite 1 - john - 2 2 - judy - 3 3 - joe - 1 the favorite icecream table is this:
6
3077
by: Xenophobe | last post by:
I know this isn't a MySQL forum, but my question is related to a PHP project. I have two tables. table1 table2 "table1" contains 2 columns, ID and FirstName:
1
1380
by: Nick | last post by:
hi, all I convert some code from access to mysql. And I have a InboxMessage table which has From and To field. So, the query is like: select * from InboxMessage where To=12 12 is user id. This query works fine in access. But does not work in Mysql. I think the problem is the field To, which must be a keyword in mysql. So, how to fix this? I don't want to change the field, becuase this will need to change a lot of code.
5
1931
by: talktozee | last post by:
Hello, everyone! Here's are the basics: 1. The query looks at all positions that are active and haven't been filled. 2. It then has to look at every single position and determine three things: Does the person running the query (via an ASP page) have certain rights? a. Recruit rights b. Enlist rights c. Take rights
2
1780
by: fusonts | last post by:
Can someon show me how to wirte a mySQL search query to search from only the open records. This is what I have but it continues to return records that are closed so I'm obviously doing something wrong. I've also tried, Where Closed = 'N' SELECT * FROM my Table WHERE Closed != 'Y' And Actionee LIKE '%colname%' OR Responsible_Org LIKE '%colname1%' OR Source Like '%colname2%' OR id LIKE '%colname5%' ORDER BY id ASC Any direction would be...
3
2623
by: xoinki | last post by:
hi all, I wanted to know few general details about MySQL slow query log. My slow log has a statement like # User@Host: root @ localhost here, what does this "" signify? why is this needed? I could not find any documentation expaining slow query log format. Regards,
2
4441
by: dvelst | last post by:
Hi All, I have the following query which was based on a working query in MySQL: (don't be afraid of the size of the query you see below, later on I will concentrate on part of this query) SELECT count(*) FROM ((SELECT * FROM tileinfo where julianDay BETWEEN DATE2JDAY(('2003-03-01 00:00:00'),0) AND DATE2JDAY(('2003-03-01 23:59:59' ),0) AND intersects(tile, geomFromText('POLYGON((-10.84 35.8,18.14 35.8,18.14 59.41,-10.84 59.41,-10.84...
2
1646
by: secutos | last post by:
I have the option of storing data online as text files, or storing data online in a MySQL database. If the information is stored as a text file, all I have to do is a HttpWebRequest to the text file to retrieve the information. I'm willing to store the information in a MySQL database if its faster. For you who want to know what I'm doing to provide a better solution, I'm simply communicating client and server through the web. I don't want to use...
0
9721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10383
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.