根据另一个表

时间:2018-02-19 11:15:02

标签: mysql sql

我想用两个不同的值插入相同的记录。我有两个separete表Table-xTable-Y

Table-x包含多个邮政编码,Table-y包含其余列。

INSERT into Table-x (id,field1,field2,zip,field3) VALUES (NULL,val1,val2,<Tabley.zipcode>,val3)

我想执行上述语句,直到Table-x有邮政编码

2 个答案:

答案 0 :(得分:1)

您可以使用WHERE .... IS NOT NULL

INSERT into Table-x (id,field1,field2,zip,field3) 
SELECT id, field1, field2, zip, field3 FROM Tabley
WHERE Tabley.zipcode IS NOT NULL

答案 1 :(得分:0)

使用public class ARFix : MonoBehaviour { private string nextScene = "QRScaner"; private bool obbisok = false; private bool loading = false; private bool replacefiles = false; //true if you wish to over copy each time private string[] paths ={ "Vuforia/FriendsJungle_DB.dat", "Vuforia/FriendsJungle_DB.xml", }; void Update() { if (Application.platform == RuntimePlatform.Android) { if (Application.dataPath.Contains(".obb") && !obbisok) { StartCoroutine(CheckSetUp()); obbisok = true; } } else { if (!loading) { StartApp(); } } } public void StartApp() { loading = true; SceneManager.LoadScene(nextScene); } public IEnumerator CheckSetUp() { //Check and install! for (int i = 0; i < paths.Length; ++i) { yield return StartCoroutine(PullStreamingAssetFromObb(paths[i])); } yield return new WaitForSeconds(3f); StartApp(); } //Alternatively with movie files these could be extracted on demand and destroyed or written over //saving device storage space, but creating a small wait time. public IEnumerator PullStreamingAssetFromObb(string sapath) { if (!File.Exists(Application.persistentDataPath + sapath) || replacefiles) { WWW unpackerWWW = new WWW(Application.streamingAssetsPath + "/" + sapath); while (!unpackerWWW.isDone) { yield return null; } if (!string.IsNullOrEmpty(unpackerWWW.error)) { Debug.Log("Error unpacking:" + unpackerWWW.error + " path: " + unpackerWWW.url); yield break; //skip it } else { Debug.Log("Extracting " + sapath + " to Persistant Data"); if (!Directory.Exists(Path.GetDirectoryName(Application.persistentDataPath + "/" + sapath))) { Directory.CreateDirectory(Path.GetDirectoryName(Application.persistentDataPath + "/" + sapath)); } File.WriteAllBytes(Application.persistentDataPath + "/" + sapath, unpackerWWW.bytes); //could add to some kind of uninstall list? } } yield return 0; }}

INSERT INTO...SELECT