union

Oracle SQL — Combining two tables, but taking duplicates from one?

我只是一个虾纸丫 提交于 2019-12-24 17:50:02
问题 I have these tables: Table A Num Letter 1 A 2 B 3 C Table B Num Letter 2 C 3 D 4 E I want to union these two tables, but I only want each number to appear once. If the same number appears in both tables, I want it from Table B instead of table A. Result Num Letter 1 A 2 C 3 D 4 E How could I accomplish this? A union will keep duplicates and an intersect would only catch the same rows -- I consider a row a duplicate when it has the same number, regardless of the letter. 回答1: Try this: http:/

how to convert an sqllite statement from '=' to MATCH instead

≯℡__Kan透↙ 提交于 2019-12-24 15:01:47
问题 I'm trying to create a dbase solution for email threading. When I receive an email.. I want to know if this email belongs to an existing thread. So I match the subject ie subject = 'cool bro' matches 're: cool bro' and i also want to match the sender and receiver pair ie (sender = 'A@gmail.com' and receiver = 'B@gmail.com') OR (sender ='B@gmail.com' and receiver = 'A@gmail.com') for those exact cases.. this query worked fine (see more details here): (SELECT COUNT(search_email.threadID) FROM

PostGIS equivalent of ArcMap Union

依然范特西╮ 提交于 2019-12-24 10:37:46
问题 What is the equivalent in PostGIS / PostgreSQL of the "Union" operation in ArcMap? Say you have two shapefiles with two features each. (PostGIS equivalent: two tables with two rows with polygon geometries) then the result would be 1 shapefile with 7 features. (PostGIS equivalent: Table with 7 rows with geometries) I've looked at ST_Intersect, ST_Union and ST_Collect but can't find the right combination. Your help is much appreciated. 回答1: Here is a working query based on this answer from gis

SQL code to generate new rows based on an existing rows

若如初见. 提交于 2019-12-24 09:29:33
问题 A recent question of mine gave me a simple method of generating data in a format like this: Date 1.0 2.0 3.0 Completed 2017-01-01 10 10 5 0 2017-02-01 10 10 5 5 2017-03-01 15 10 5 15 2017-04-01 15 10 5 25 That data represents the "burnup" data for an Agile project. That is just the past data, though, and we need to predict the future data too. Only the Date and the Completed values will change in the future, and they will increment by values in another table, like Project Velocity Days Foo 25

Union Query Across Databases

守給你的承諾、 提交于 2019-12-24 08:58:49
问题 I want to run a union query on qry_1 in C:\DB\DB1.mdb and qry_2 in C:\DB\DB2.mdb All examples I have seen only show how to run a Union Query on query's in the same database, how can you do this when the query's are in different databases? EDIT --- Grr, not quite displaying results like I was after. That shows each entry twice. Is there a way to only show the entry one time? For example if qry_1 returns Joe 14, Jack 16, Jimmy 12 and qry_2 returns Joe 22, Jack 48, Jimmy 66 is there a way to SUM

Q: Match rows and Insert return value in SQL (Complex condition)

廉价感情. 提交于 2019-12-24 07:49:48
问题 This is the Problem Table: UNIQUE ID NAME TYPE PRICE PAYMENT METHOD Reference hbg5-5rdw-6ts Bagui RECEIVED 150 MANUAL CREDIT CARD asd4e-4rs-5tg Cams RECEIVED 100 CASH 181088 fg6gh-rfd4-tgv Cams TRANSFER 100 CASH 181088 a3accf-wrf-aw Chels RECEIVED 700 MANUAL COD 1sder-5tg7-gcd Chels SUCCESS 500 CHECK asde-1d-sedc Chels SUCCESS 500 CHECK 1sder-5tgs7-gcd5 Failed ased-asd-sedf Duzy RECEIVED 250 DEBIT 181077 5rt4w-4sd-zsd Duzy TRANSFER 250 DEBIT 181077 4er-445ff-thc Jose RECEIVED 300 CASH 157075

sorting error in union query

Deadly 提交于 2019-12-24 06:51:12
问题 SELECT DISTINCT rt . d_rev_id , rt . d_rev_code , rt . d_reason , rt . d_rev_status , rt . d_apb , rt . d_cb , pt . d_partid , pt . d_part_no , pt . d_ab , pt . d_abd , pt . d_status , rt . d_part_name , rt . d_part_desc , rt . d_part_type , pnv . d_pn_val , pnv . d_pn_id , cfv . d_optionname , rt . d_projectid , rt . d_abd , rt . d_apbd FROM ( ( design_parts pt INNER JOIN design_part_number_val pnv USING ( d_partid ) INNER JOIN design_revision_temp rt USING ( d_partid ) ) LEFT JOIN design_pn

sorting error in union query

 ̄綄美尐妖づ 提交于 2019-12-24 06:51:09
问题 SELECT DISTINCT rt . d_rev_id , rt . d_rev_code , rt . d_reason , rt . d_rev_status , rt . d_apb , rt . d_cb , pt . d_partid , pt . d_part_no , pt . d_ab , pt . d_abd , pt . d_status , rt . d_part_name , rt . d_part_desc , rt . d_part_type , pnv . d_pn_val , pnv . d_pn_id , cfv . d_optionname , rt . d_projectid , rt . d_abd , rt . d_apbd FROM ( ( design_parts pt INNER JOIN design_part_number_val pnv USING ( d_partid ) INNER JOIN design_revision_temp rt USING ( d_partid ) ) LEFT JOIN design_pn

How to use Regexp.union to match a character at the beginning of my string

▼魔方 西西 提交于 2019-12-24 06:04:07
问题 I'm using Ruby 2.4. I want to match an optional "a" or "b" character, followed by an arbitrary amount of white space, and then one or more numbers, but my regex's are failing to match any of these: 2.4.0 :017 > MY_TOKENS = ["a", "b"] => ["a", "b"] 2.4.0 :018 > str = "40" => "40" 2.4.0 :019 > str =~ Regexp.new("^[#{Regexp.union(MY_TOKENS)}]?[[:space:]]*\d+[^a-z^0-9]*$") => nil 2.4.0 :020 > str =~ Regexp.new("^#{Regexp.union(MY_TOKENS)}?[[:space:]]*\d+[^a-z^0-9]*$") => nil 2.4.0 :021 > str =~

Laravel 4.2 union

与世无争的帅哥 提交于 2019-12-24 02:33:22
问题 For the following request: $gamer_id = DB::table('users_relations')->select('gamer_id')->where('user_id', '=', Auth::user()->id)->first(); $test_id = DB::table('users_relations')->select('gamer_id')->where('user_id', '=', 2)->first(); $results = $gamer_id->union($test_id)->get(); dd($results); I have the error: Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to undefined method stdClass::union() Any thought about that ? Thank you! P.S. Documentation -−> http://laravel.com