union

PHP MySQL query using UNIONs and locating which table the data came from

拟墨画扇 提交于 2020-01-05 08:55:10
问题 So I have a query that I am selecting values from two different tables and UNIONizing them together. I need to know where which entry came from as I need to form a different URL for each. What is the best way and proper syntax to tag both of these SELECT queries. Any help would be appreciated. Code to follow: $query = "SELECT newsletter_id id, newstitle title FROM tbl_news WHERE (newstitle LIKE '%".stripslashes($rowCont->fname)."%' && newstitle LIKE '%".stripslashes($rowCont->lname)."%') ||

How to write union query in Laravel?

天涯浪子 提交于 2020-01-04 09:26:27
问题 I'm using laravel 5.0 and I have mysql query: SELECT surat_masuk.id_surat, surat_masuk.nomor_surat FROM surat_masuk WHERE ! EXISTS (SELECT * FROM file_replace WHERE id_surat_lama = surat_masuk.id_surat) AND surat_masuk.id_jenis_surat = '6' AND surat_masuk.deleted = '0' UNION SELECT id_surat_lama FROM file_replace WHERE id_surat_baru = '38' And I write that in my laravel code into: $nomor_surat1 = DB::table('surat_masuk')->select('id_surat', 'nomor_surat') ->where('id_jenis_surat', '=', $id

error -1054 unknown column e.id in order clause

删除回忆录丶 提交于 2020-01-04 06:43:14
问题 I have a query like this - SELECT e.id FROM event e WHERE e.startdatetime<NOW() AND e.isEventDeleted=FALSE AND e.isNeighborlyInvited=TRUE AND e.organized_by!=49 AND e.event_address IN (SELECT id FROM address a WHERE latitude!='' AND longitude!='' AND IFNULL(( 3959 * ACOS( COS( RADIANS(22.6979425) ) * COS( RADIANS( latitude ) ) * COS( RADIANS( longitude ) - RADIANS(75.8597305) ) + SIN( RADIANS(22.6979425) ) * SIN( RADIANS( latitude ) ))),0)<100) AND e.id NOT IN (SELECT eventid FROM event

mysql union wrong columns in result

落花浮王杯 提交于 2020-01-04 06:14:24
问题 I am getting wrong column names when using union. Here is what i do, i have two very big tables with same structure and different records, so here it is. mysql> select * from e18 where `15` like '%car%' limit 1; +------+------+----+------+------+------+------+------+------+------+------+------+------+------+------+-------------+------+------+------+------+------+------+--------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+------+-----------

EF Code First - Linq to Entities Union EqualityComparer

♀尐吖头ヾ 提交于 2020-01-04 04:14:30
问题 I have two IEnumerable collections that I would like to union. One selects news objects that are associated with a particular category. When a user is filtering by a category I would also like news articles that have been tagged with another category to be displayed. So I have another query that returns news objects that are tagged with the particular sub category. Now I would like to union the two collections, removing duplicates (as a news article associated to the main category, may also

sql 2005 如何一次导入多条数据

走远了吗. 提交于 2020-01-03 19:09:23
INSERT INTO #ppe02 (pdctno) select '2318227C0' union all select '2318230C0' union all select '2318428A0' union all select '1486004A0' union all select '2318311D0' union all select '2318348A1' INSERT INTO #ppe02 (pdctno) select '1071014B1' union all select '2071314A3' union all select '2204101A1' union all select '2001045C1' union all select '1486004A0' union all select '2001663A0' union all select '2071508A0' union all select '1318004B0' union all select '2071346A0' union all select '2071347A0' union all select '2071364A1' union all select '2071365A1' union all select '2071368A0' union all

How to combine multiple tables that vary slightly in columns

我是研究僧i 提交于 2020-01-03 18:33:11
问题 I have multiple tables where there are roughly 10 common columns, but some tables have 1-2 extra columns. I would like to combine all these tables into one table with a row for each row from each table, with NULL values for any columns that didn't exist in each particular row's source table. So my inputs look roughly like this: table1 id | colA | colB table2 id | colA | colB | colC table3 id | colA | colB | colD And I am trying to get this: allTables id | colA | colB | colC | colD In the

MySQL consolidate duplicate data records via UPDATE / DELETE

你说的曾经没有我的故事 提交于 2020-01-03 16:15:10
问题 I have a table which looks like this: mysql> SELECT * FROM Colors; ╔════╦══════════╦════════╦════════╦════════╦════════╦════════╦════════╗ ║ ID ║ USERNAME ║ RED ║ GREEN ║ YELLOW ║ BLUE ║ ORANGE ║ PURPLE ║ ╠════╬══════════╬════════╬════════╬════════╬════════╬════════╬════════╣ ║ 1 ║ joe ║ 1 ║ (null) ║ 1 ║ (null) ║ (null) ║ (null) ║ ║ 2 ║ joe ║ 1 ║ (null) ║ (null) ║ (null) ║ 1 ║ (null) ║ ║ 3 ║ bill ║ 1 ║ 1 ║ 1 ║ (null) ║ (null) ║ 1 ║ ║ 4 ║ bill ║ (null) ║ 1 ║ (null) ║ 1 ║ (null) ║ (null) ║ ║ 5

Representing union bitfields using c#'s StrucLayout and FieldOffset

回眸只為那壹抹淺笑 提交于 2020-01-03 11:45:32
问题 I understand that in order to represent unions in C# I need to use StructLayout[LayoutKind.Explicit)] and [FieldOffset(x)] attribut to specify the byte offset inside the union. However, I have a following union I want to represent and FieldOffset attrib only offset by size of a byte. union _myUnion { unsigned int info; struct { unsigned int flag1:1 // bit 0 unsigned int flag2:1 // bit 1 unsigned int flag3:1 // bit 2 unsigned int flag4:1 // bit 3 unsigned int flag5:1 // bit 4 unsigned int

LINQ to Objects .Distinct() not pulling distinct objects

匆匆过客 提交于 2020-01-02 06:24:12
问题 I have two ways that I am doing a fuzzy search for a customer. One is by an abbreviated name and the other is by the customer's full name. When I take these two result sets and then union them together (which I have read several places should remove distinct values) I get duplicates. Thinking that all I need to do is then call the .Distinct() method on this, I also still get duplicates. Do I need to implement some compare functionality in my customer object? My code: Dim shortNameMatch As