not-exists

Insert New Row in Table 3 if combination of Col A and Col B in Table C Don't Exist

二次信任 提交于 2019-12-07 20:50:39
问题 I have a code that gets data from Tables 1 and 2, and then inserts new rows into Table 3. My problem is that the code adds records that already exist. How can I prevent duplicate errors from being inserted, when the combination of groupid and userid in Table C already exists? INSERT INTO mdl_groups_members (groupid,userid) SELECT l.mgroup AS moodle, r.id AS mdl_user FROM moodle AS l JOIN mdl_user AS r ON l.orders_id = r.id WHERE l.mgroup > 0 Here's the table before I ran the script: id

check if a key exist firebase Android

浪子不回头ぞ 提交于 2019-12-07 07:24:08
问题 I want to check if a key exist in the firebase db. so for example, I want to look for the key "upvotes" to see if it exist or not. Here is an exmaple, "upvotes" key does not exist in here: Now I my attempt to check if the key "upvotes" is at this location: Map<String, Object> newPost = (Map<String, Object>) ids.next().getValue(); if(newPost.get("upvotes").toString().equals("upvotes")){ disp_rate = newPost.get("upvotes").toString(); } else { disp_rate = "0"; } My attempt is wrong, so how do I

SQL - not exists query with millions of records

给你一囗甜甜゛ 提交于 2019-12-06 13:30:53
I'm trying to use the following SQL query (in SAS) to find any records from pool1 that do not exist in pool2 . Pool1 has 11,000,000 records, pool2 has 700,000. This is where I run into an issue. I let the query run for 16 hours and it was nowhere near finishing. Is there a more efficient way (in SQL or SAS) to achieve what I need to do? PROC SQL; CREATE TABLE ALL AS SELECT A.ID FROM POOL1 A WHERE NOT EXISTS (SELECT B.ID FROM POOL2 B WHERE B.ID = A.ID); QUIT; Steve Matthews PROC SQL; CREATE TABLE ALL AS SELECT A.ID FROM POOL1 A WHERE A.ID NOT IN (SELECT B.ID FROM POOL2 B) ; The above change

mysql insert if row does not exist already in a table with NO UNIQUE FIELDS

我只是一个虾纸丫 提交于 2019-12-06 09:32:20
问题 Looking for a while now already for how to accomplish this. Seems that all solutions need unique fields with indexes. 回答1: there is no IF NOT EXISTS syntax in INSERT , but you could make use of the ON DUPLICATE KEY mechanism. Assuming you create a unique index on firstname, lastname, your update might read: INSERT INTO tb (firstname, lastname) VALUES ('Jack', 'Doe') ON DUPLICATE KEY UPDATE lastname = lastname; which renders the insert neutral. 回答2: Have you already considered the INSERT OR

Insert New Row in Table 3 if combination of Col A and Col B in Table C Don't Exist

a 夏天 提交于 2019-12-06 07:58:29
I have a code that gets data from Tables 1 and 2, and then inserts new rows into Table 3. My problem is that the code adds records that already exist. How can I prevent duplicate errors from being inserted, when the combination of groupid and userid in Table C already exists? INSERT INTO mdl_groups_members (groupid,userid) SELECT l.mgroup AS moodle, r.id AS mdl_user FROM moodle AS l JOIN mdl_user AS r ON l.orders_id = r.id WHERE l.mgroup > 0 Here's the table before I ran the script: id groupid userid timeadded 1 1 1 1372631339 2 4 2 1372689032 3 8 3 1373514395 4 3 4 1373514395 Here's the table

Key “path” for array with keys “” does not exist while dump says it does

独自空忆成欢 提交于 2019-12-06 02:14:12
问题 I'm currently working on a cms using symfony2 as the underlying framework and twig as the template engine. My problem is the following: While this {% for image in images %} {{ dump(image.path is defined) }} {% endfor %} returns true for each element in the array,... ...but this one {% for image in images %} {{ image.path}} {% endfor %} throws an exeption. Key "path" for array with keys "" does not exist A twig-dump of the images-array returns this: array(2) { [0]=> object(stdClass)#2759 (9) {

in bash find all files in flat directory that don't exist in another directory tree

老子叫甜甜 提交于 2019-12-05 23:21:04
I have many files in a directory A . Some of those files exist in a directory tree with sub-directories B/B1 , B/B2 , B/B3 , B/B4 , ... Note that some files have spaces in their names. For example: in directory A : there's a file named A/red file.png there's another named A/blue file.png and, in directory tree B : there's a file named B/small/red file.png In this example, I would like a script to tell me that the file blue file.png does not exist in the directory B . How can I write a script that will list all the files in A that are not found under the directory tree B ? # A # ├── blue file

Magento: addAttributeToFilter but ignore for products that don't have this attribute?

给你一囗甜甜゛ 提交于 2019-12-05 17:07:27
I'm trying to show add some filters on my store, but they have a nasty side effect. Suppose I have product type A and B. Now I want to only show A where color = blue/red. $collection = Mage::getResourceModel('catalog/product_collection') ->setStoreId($this->getStoreId()) ->addCategoryFilter($this) ->addAttributeToFilter(array( array('attribute' => 'color', 'in' => array(4, 6)), ) ); This does the trick, but now because product type B has no value assigned to color(since this attribute isn't appointed to it) no products fo this type show up. I had found this code on the forum http://www

Django migration dependencies reference nonexistent parent node

房东的猫 提交于 2019-12-04 05:22:39
问题 I have a problem with django migrations. I get this error: django.db.migrations.exceptions.NodeNotFoundError: Migration user.0050_merge_20170523_1254 dependencies reference nonexistent parent node ('user', '0049_auto_20170519_1934') I fix the errors, deleting some lines but after fix all this errors, I get other: ValueError: Could not find common ancestor of {'0050_merge_20170523_1254', '0007_auto_20170524_1540'} I cant solve that. I can drop database and do makemigrations again... but in

SQL - improve NOT EXISTS query performance

倖福魔咒の 提交于 2019-12-03 05:18:39
Is there a way I can improve this kind of SQL query performance: INSERT INTO ... WHERE NOT EXISTS(Validation...) The problem is when I have many data in my table (like million of rows), the execution of the WHERE NOT EXISTS clause if very slow. I have to do this verification because I can't insert duplicated data. I use SQLServer 2005 thx Make sure you are searching on indexed columns, with no manipulation of the data within those columns (like substring etc.) Off the top of my head, you could try something like: TRUNCATE temptable INSERT INTO temptable ... INSERT INTO temptable ... ... INSERT