w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
SQL UNION result not the same as the result of individual statements?
Yes. Absolutely. The union removes duplicates. If you want the same results, use union all. Also note: the ordering after union and union all is not guaranteed. If you want things in a particular order, use order by.

Categories : SQL

Desirable result in "UNION"
This is not possible. The column names will be the same throughout the query result. Those column names are actually the column names of the query result and don't need to be the same as column names in the table(s): SELECT id as Numbers, content as Texts FROM table1 UNION ALL SELECT p_id, p_content FROM table2; You can execute two separate queries and process their results separately. Or otherwise you could return an extra constant value to determine between the results: SELECT id, content, '1' as TableNr FROM table1 UNION ALL SELECT p_id, p_content, '2' FROM table2; Now, for each row you can ask the value of the column 'TableNr' to see which table it came from.

Categories : PHP

I have two selects and I want the result table to be a union of the two
So join them: Select t1.idRoom, t1.ExistingComputers, t2.UsedComputers (select room.idRoom, count(*) as ExistingComputers from room, computer where room.idRoom = computer.idRoom group by room.idRoom) t1 inner join (select room.idRoom, count(*) as UsedComputers from room, session, computer where room.idRoom = computer.idRoom and computer.idComputer = session.idComputer and session.logout is null group by room.idRoom) t2 on t1.idRoom = t2.idRoom I've kept your pseudo-code as is. The basic idea is that you give an alias to the first table you're selecting and an alias to the second table you're selecting and then join them on idRoom.

Categories : Mysql

Use Aggregate Function in UNION ALL result set
Try this way: select max(A) from( SELECT A,B FROM MyTable UNION ALL SELECT B,C FROM MYAnotherTable ) Tab SQL Fiddle DEMO If the column A is varchar (You said that in the comment below) try this way: select max(A) from( SELECT cast(A as int) as A,B FROM MyTable UNION ALL SELECT B,C FROM MYAnotherTable ) Tab With TOP 1 select max(A) from( SELECT top 1 cast(A as int) as A,B FROM MyTable UNION ALL SELECT B,C FROM MYAnotherTable ) Tab

Categories : SQL

how to union two queries in stored procedure to get result in one row
You could use a cross join instead of a union: select q1.TotalQuote , q1.QuoteAmount , q2.TotalOrders , q2.OrderAmount from ( ... first query ... ) q1 cross join ( ... second query ... ) q2

Categories : Sql Server

UNION on 2 tables returns one almost empty result every time
The reason you are getting these results back is because you are using an outer join on the table. Try this instead: SELECT * from ( SELECT g.id AS gallery_id, 'photo' AS type, p.id AS id, p.filename, p.caption, null AS title, null AS service, null AS embed, null AS width, null AS height, p.display_order FROM galleries g JOIN photos AS p ON p.gallery_id = g.id WHERE g.id = {$this->id} UNION SELECT g.id AS gallery_id, 'video' AS type, v.id AS id, null AS filename, null AS caption, v.title, v.service, v.embed, v.width, v.height, v.display_order FROM galleries g JOIN videos AS v ON v.gallery_id = g.id WHERE g.id = {$this->id} ) AS u ORDER BY display_order; Also, it sounds like you might get a lot of benefit from reading this article I w

Categories : PHP

union find disjoint set weighted quick union with path compression algorithm
As far as I understood the code, the array iz[] represents the amount of elements in a given disjoint set. When you compress the path, you don't modify that number for each set. Thus, the path compression does not affect the iz[] array.

Categories : Java

Access: Overflow Error with UNION but not with UNION ALL or Individual Queries
"Why would I get an overflow error when using a UNION query and not with UNION ALL??" You indicated you're aware that UNION returns only distinct rows, and UNION ALL returns all rows including duplicates. With just UNION, the db engine must apply a sort to the initial working set so that it can identify which are the duplicate rows and eliminate them from the final result set. That sort operation imposes a significant additional burden on the db engine, which incidentally explains why UNION ALL is always faster than UNION, quite often dramatically faster. In your case, the individual SELECT statements already impose an unusual burden on the db engine. Never before have I seen an Access query which uses Nz() 67 times and adds all those values to derive one calculated field. And the db

Categories : SQL

Anonymous union and a normal union
As far as I know, anonymous structs don't exist in standard C++, although they may be supported by some compilers. Anonymous unions can't have protected or private members. The members are accessed without using the union's name (clearly, as it doesn't have one!). Global anonymous unions (God forbid) must be declared static.

Categories : C++

How can I isolate the result of scipy.integrate.quad function, rather than having the result and the error of the calculation?
integrate.quad returns a tuple of two values (and possibly more data in some circumstances). You can access the answer value by referring to the zeroth element of the tuple that is returned. For example: # import scipy.integrate from scipy import integrate # define the function we wish to integrate f = lambda x: x**2 # do the integration on f over the interval [0, 10] results = integrate.quad(f, 0, 10) # print out the integral result, not the error print 'the result of the integration is %lf' % results[0]

Categories : Python

How to update Linq result with in the list, without assign other data table process itself get another one result
It working dim L1 = (From cm in commontables select cm) L1.Where(Function(T) T.Address is nothing).ToList() For i =0 to L1.count-1 step 1 L1(i).Address="Address1" Next

Categories : Dotnet

Access 2010 Only returning first result Regular Expression result from MatchCollection
This function is only returning one value because that's the way you have set it up with the logic. This will always return the last matching value. For Each foundMatch In foundMatches OrderMatch = foundMatch.Value Next Even though your function implicitly returns a Variant data type, it's not returning an array because you're not assigning values to an array. Assuming there are 2+ matches, the assignment statement OrderMatch = foundMatch.Value inside the loop will overwrite the first match with the second, the second with the third, etc. Assuming you want to return an array of matching values: Dim matchVals() as Variant Dim m as Long For Each foundMatch In foundMatches matchValues(m) = foundMatch.Value m = m + 1 ReDim Preserve matchValues(m) Next OrderMatch = ma

Categories : SQL

How to return a result at the moment of an interrupt a.k.a. how to retrieve the result of a Callable although it's cancelled
So, there is one thread performing the computation; this thread is interrupted and the "best result" is what it could come up with. Then you can, instead of a Callable, use a Runnable and pass a reference to a structure bearing the result when you initialize it. You can then submit that runnable to your thread pool; when it is "done with its work" (either it is really done, or it was interrupted), you'll just have to read the data in the reference you passed to your Runnable as an argument. EDIT Since the result of the computation is a( reference to a)n object, I suggest the use of an AtomicReference.

Categories : Java

Inner join query returning all NULL result when it should return no result
Problem is that you are using an aggregate function (AVG). This is going to give you a single row (in the abscence of a GROUP BY clause), even with no actual matching rows. Try this:- SELECT a.account_id, a.first_name, a.second_name, a.points, c.body, c.creation_time, AVG(t.rating_overall) FROM comments AS c INNER JOIN accounts AS a ON c.account_id=a.account_id INNER JOIN ratings AS t ON t.blogger_id=a.account_id WHERE c.blog_id = ? GROUP BY a.account_id, a.first_name, a.second_name, a.points, c.body, c.creation_time ORDER BY c.creation_time ASC

Categories : Mysql

$nearSphere query gives result java but how to calculate distance of each result?
If you use the $geoNear aggregation command, you will also get the calculated distance back as well. I found this in a presentation given at MongoDB London this year, it describes the use of $geoNear (slides 36 and 37), along with other geo features in MongoDB. Alternatively, you can get an understanding of how some of the MongoDB geo features work in some of the following presentations: Geo features webinar Geospatial Enhancements in MongoDB 2.4 video I'm sure you've already found this via Google, but the MongoDB website has documentation on Geospatial indexes/queries

Categories : Java

Foreach loop to see result in Rich text box but only seeing first query result.?
You can use OracleDataReader like below to display results if you have more records returning from the query, and also never use inline parameters in your sql, better to use parameterized query to avoid sql injection attacks. using (OracleCommand crtCommand = new OracleCommand(sql, Con)) using (OracleDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { if(!reader.IsDBNull(0)) richTextBox1.AppendLine(reader[0].ToString(); + ";"); } }

Categories : C#

entry in input one by one should show added result in result field
If you are using chrome, then console is your best friend ( https://developers.google.com/chrome-developer-tools/docs/console ) For firefox you have firebug, opera has dragonfly (or something like that ?). Even IE has console now. There you can see all errors popping up. Ok, so first of all let's clean up this a little bit by wrapping it all in closure (we can now safely use the $ instead of jQuery even if there is namespace conflict outside). Also, we will use single function for both cases, because they are so similar. !function ($) { $(".txt-email").keyup(setValue); $('.rdbtn-style-social').change(function(e) { setValue(e, true) }); function setValue(e, radio) { if('undefined' === typeof radio) radio = false; var attr = radio ? 'name' : 'id'; var

Categories : Javascript

No result defined for action actions.AddExam and result input
The result input is triggered when some validation over the form is not correct. You must add that result into your mapped action tag over struts.xml: <action name="addExam" class="actions.AddExam"> <result name="success" type="chain">display-exams</result> <result name="error">/add_exam.jsp</result> <result name="input">/add_exam.jsp</result> </action> Doing that maybe you don't need that <result name="error">.

Categories : Java

How to get result from stored procedure and save result in a class attributes
You need to use a SqlDataReader to read the result set returned by the stored procedure: using (SqlConnection conn = new SqlConnection(Connection.getConnection())) using (SqlCommand sp = new SqlCommand("dbo.selectAllItems", conn)) { sp.CommandType = CommandType.StoredProcedure; sp.Parameters.Add("@ItemCode", SqlDbType.Int).Value = your-item-code-value-here; conn.Open(); using (SqlDataReader rdr = sp.ExecuteReader()) { while (rdr.Read()) { // read the values from the data reader, e.g. // adapt to match your actual query! You didn't mentioned *what columns* // are being returned, and what data type they are string colValue1 = rdr.GetString(0); int colValue2 = rdr.GetInt(

Categories : C#

Difference between returning result and assigning result through pointer argument?
For complex return types you're probably right, that there is no difference. For simple return types, the compiler will return the result in a register, e.g. for int foo(...); but if you pass a pointer to result storage, like this: void foo (int* result, ...); it can't (at least not in the general case). But let me suggest to worry about optimization later and ignore the possible performance impact. If you're not an experienced language designer, you'll have other problems to worry about. And later, dependent on you're design, you'll have other opportunities to optimization. In example: If you generate all C code into one file, you could let the c compiler do aggressive inlining - which AFAICS will remove the perfomance difference we just have been talking about.

Categories : C

MySQL Query Result Offset With Limit With New Result Possibility?
You might want to try a database solution. On the initial request, create and populate a table. Use that table for the feed. Make sure the tablename starts with something consistent, like TableToFeedMyApp, and ends with something guaranteed to make it unique. Then set up a scheduled job to find and drop all these tables that were created earlier than whatever you deem to be a certain interval.

Categories : PHP

How to output one result from a duplicated result using regular expressions?
Description Given a space delimited list of values like £1.00 £2.00 £2.00 £1.00 £1.00 you can validate if there are duplicates by using a negative look ahead to find a back referenced value. I also added a $ and sign to the character class to allow for multiple currency types. This will return the last instance of each value which essentially makes the output unique. Regex: (?:s|^)((?:£|$|xC2|xA3)d+.d{1,2})(?=s|$)(?!.*?s1(?=s|$)) Input: £1.00 £2.00 £2.00 £1.00 £1.00 link to example $matches Array: ( [0] => Array ( [0] => £2.00 [1] => £1.00 ) [1] => Array ( [0] => £2.00 [1] => £1.00 ) ) So we can carry this idea a step further to include your test expression &

Categories : Regex

node js restler result "get" not complete when trying to return result
Would your return resultstr; not run before the on('complete' callback gets called because it is asynchronous, therefore resulting in your htmlstring being null? I think you need to have a callback as a parameter to your loadHtmlUrl like so: var rest = require('restler'); var loadHtmlUrl = function(weburl, callback) { var resultstr = rest.get(weburl).on('complete', function(result) { callback(result.request.res.rawEncode); }); }; And then call it like so: var htmlstring = null; loadHtmlUrl('http://google.com', function(rawEncode) { htmlstring = rawEncode; //Do your stuff here... }); I think that will resolve future problems you will have. However, I think the real problem you're facing is that result.request does not have the property of res. I'm thinking that my c

Categories : Node Js

Converting result of Math.sin(x) into a result for degrees in java
You can convert radians to degrees like this: double rad = 3.14159; double deg = rad*180/Math.PI; And the reverse to convert degrees to radians (multiply by pi/180). You can't change the "input method" for Math.sin (you can't tell the function to use degrees instead of radians), you can only change what you pass it as a parameter. If you want the rest of the program to work with degrees, you have to convert it to radians especially for Math.sin(). In other words, multiply the degrees value by pi and divide by 180. To use this with Math.sin(), just convert it like so: double angle = 90; //90 degrees double result = Math.sin(angle*Math.PI/180); Just using the conversion by itself doesn't change anything, you have to pass the converted value to the sin function.

Categories : Java

Python: Why this tuple is printing the result and "None"? Also: Is there a better way to achieve the result?
Change "print" to "return" inside your function and that should fix it when you call "print stamps(8)". Also, no, for your simple choice of stamp values 5,2,1, there is no more efficient way to find a good solution other than what you're doing (the only possible improvement would perhaps to use a for loop if you had more stamp values than just 3) -- if your stamp values were more complex, then you could find better solutions that use fewer stamps by using dynamic programming.

Categories : Python

PHP search result output different result if you give one letter only
Your sql query needs to group your conditions properly $query=mysql_query("select * from persons where status like 'found' and (firstname like '%$searchtext%' or lastname like '%$searchtext%') order by date desc LIMIT $start,$per_page "); What you were doing is equivalent to something like this in code: if (status == 'found' && firstname like 'a') { return row; } else if (lastname like 'a') { return row; } If you see this it may be a bit clearer, if the first condition fails (the only one that checks if status == 'found' then it will skip to the next condition (after the OR statement) and only check if lastname matches. You will need to group your select statement condition so it checks it correctly: ...where status like 'found' and (firstname like '%$searchtext%' o

Categories : PHP

UNION ALL and NOT IN together
The parts of a UNION are handled as separate queries, so you can group them in a subquery: SELECT Name FROM (Select Name from Fname UNION ALL Select Name from Lname)sub WHERE Name NOT IN (Select Name from Exceptions) You can keep that as UNION ALL if you don't care about duplicates.

Categories : SQL

SQL Union with CTE and Sum
You can perform aggregate functions on the results of a UNION statement as a sub-query. There may be some variations depending on your specific DBMS, but This sample meta-code should explain the concept: SELECT "Results".ColA, "Results".SUM(ColB), "Results".SUM(ColC) FROM ( SELECT ColA, ColB, ColC FROM SomeTable1 INNER JOIN SomeOtherTable1 WHERE Criteria UNION SELECT ColA, ColB, ColC FROM SomeTable2 INNER JOIN SomeOtherTable2 WHERE Criteria ) "Results" GROUP BY "Results".ColA

Categories : SQL

result of array from query only shows one result?
First of all, change this: while ($row = mysqli_fetch_assoc($result)) { to this: while ($row = $result->fetch_assoc()) { You were mixing mysqli's object-oriented and procedural styles, which can cause problems. The fetch_assoc documentation has more information. Then, just put the $array assignment inside the while loop: while ($row = $result->fetch_assoc()) { $array[] = array( "result" => "1", "id" => $row['id'], "subject" => $row['subject'], "chatbox_id" => $row['chatbox_id'] ); } After this while loop finishes, $array will be an array of associative arrays. You can use it like this: foreach($array as $db_row) { echo "This row's id is " . $db_row['id'] . '<br />'; echo "This row's subject is " . $db_row['s

Categories : PHP

UI thread waits for Async result and act according to result
The AsyncTask is what you are looking for! There is an example. Feel free to ask, if you have any questions!

Categories : Android

get one result at a time from database (when more than one result exists)
What is the query/code you are using to get all of column two as a string? It is always a good idea to test your query in the database system itself or you could use SQLFiddle to ensure you are getting the results you are expecting from your query From the Doc: A ResultSet object maintains a cursor pointing to its current row of data. Initially the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set. Read the rest of Java Doc for ResultSet A typical approach to getting values from the data base is to //Construct a statement String yourStatement = "Select COLUMN_B from aTable WHERE COLUMN_A LIKE '

Categories : Java

join multiple result to one result in sql server
It looks like dates can be missing from either table so a FULL JOIN would appear to be more appropriate and use ISNULL to get 0 when the counts for that day are null Try: ; WITH cnt AS ( SELECT e.ecode, Cast(q.dtime AS DATE) AS Date, e.ename, Count(q.ecode) cntEcode FROM employeemaster_tbl e JOIN transaction_tbl q ON e.ecode = q.ecode WHERE q.ecode = @Ecode AND dtime >= '' + @date1 + '' AND dtime <= '' + @date2 + '' GROUP BY e.ecode, e.ename, Cast(q.dtime AS DATE) ), del AS ( SELECT e.ecode, Cast(q.dtime AS DATE) AS Date, e.ename, Count(q.delecode) DelEcode FROM employeemaster_tbl e JOIN transaction_tbl q ON e.ecode = q.delecode WHERE q.delecod

Categories : Sql Server

Bitwise shifting operation gives a 32-bit result instead of a 64-bit result in VB.NET
When using bitwise operators and constants make sure that the constant type reflects your usage. This Dim u As Long = 1 << 32 and this Dim u As Long = 1L << 32 produce different results. I also notice that your function readDword is only producing an integer both as a return and internally.

Categories : Vb.Net

add rowcount in s.p with union
For more detailed information about using the ROW_NUMBER ranking function, see MSDN ALTER PROCEDURE [dbo].[SP_sum_inventory_byproduct_by_date_range] ( @salesdate datetime , @upsalesdate1 datetime ) AS BEGIN SET NOCOUNT ON; SELECT ROW_NUMBER() OVER(ORDER BY new.ItemCode) AS rn, new.ItemCode, SUM(new.Quantity) AS Quantity FROM ( SELECT T1.ItemCode, SUM(T1.Quantity) FROM iiii T0 INNER JOIN ffff T1 ON T0.DocEntry = T1.DocEntry INNER JOIN oooo t2 on t0.cardcode=t2.cardcode WHERE T0.DocDate >= @salesdate and T0.DocDate <= @upsalesdate GROUP BY T1.ItemCode, T1.Dscription UNION SELECT T1.ItemCode , T1.Dscription , -SUM(T1.Quantity) FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN ococ t2 on t0.cardcode=t2.cardcode

Categories : SQL

SQL - Sum within UNION query
You removed lw status and didn't select anything: UNION SELECT 'SUM', sum(IIF(layer='key info',1,0)) AS [Key Info], sum(IIF(layer='approaches',1,0)) AS [Approaches], sum(IIF(layer='research',1,0)) AS [Research] FROM resources UNION <Next Query>

Categories : SQL

Union All Command in SQL
Try this Query: SELECT a.VPNID||'|'||a.PUBLICNUMBER||'|'||a.PRIVATENUMBER||'|'||'NULL' from virtualterminal a UNION ALL SELECT b.VPNID||'|'||b.PUBLICNUMBER||'|'||b.PRIVATENUMBER||'|'||b.PROFILEID from terminal b;

Categories : SQL

How to get sum of particular column in last row with union
You can use a window function to get the sum of the average: SELECT Employees.EmployeeID AS EMPLOYEEID, Employees.EMPLOYEENAMESURNAMEFORMAT AS LastFirstName, SUM(MAILCOUNT) MAILCOUNT, COUNT(*) DAYCOUNT, AVG(MAILCOUNT) AVERAGE , sum(avg(MAILCOUNT)) over () as SUMAVERAGE FROM Employees LEFT JOIN ST_LAWERP_DAILYMAIL_PERFORMANCE ON Employees.EmployeeID = ST_LAWERP_DAILYMAIL_PERFORMANCE.EMPLOYEEID WHERE Employees.ACTIVESTATUS = 1 AND Employees.Loginname<>'' AND Employees.Title NOT IN ('Chauffeur','Intern','Summer Intern') AND ST_LAWERP_DAILYMAIL_PERFORMANCE.DATE BETWEEN '2011-01-01' AND '2015-01-01' GROUP BY Employees.EmployeeID,Employees.EMPLOYEENAMESURNAMEFORMAT

Categories : SQL

Linq one-to-many Union
So you're looking for three different sets, all combined. Just query each of those three things and then combine them using Union: string user = "Joe"; var addedOrganizations = context.Organizations.Where(org => org.AddedBy == user); var orgsWithUsersComments = from org in context.Organizations join c in context.Comments on org.OrganizationID equals c.OrganizationID where c.AddedBy == user select org; var orgsWithUsersProposals = from org in context.Organizations join p in context.Proposals where p.AddedBy == user select org; var combinedResults = addedOrganizations.Union(orgsWithUsersComments) .Union(orgsWithUsersProposals);

Categories : C#

GCC transparent union
Mate, this code worked for me: #include <stdint.h> typedef union { uint8_t *b1; uint16_t *b2; uint32_t *b3; uint64_t *b4; } buffer_u __attribute__((__transparent_union__)); int write_byte_to_buffer(buffer_u buf, uint16_t length, uint8_t val) {return 0;} int write_short_to_buffer(buffer_u buf, uint16_t length, uint16_t val) {return 0;} int write_int_to_buffer(buffer_u buf, uint16_t length, uint32_t val) {return 0;} int write_long_long_to_buffer(buffer_u buf, uint16_t length, uint64_t val) {return 0;} int main (int argc, char *argv[]) { uint8_t p[100]; write_byte_to_buffer(p, 1, 100); return 0; } Gcc version: fanl@ubuntu-StiDesktop:~$ gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc.

Categories : C

Sub select & union all
The UNION clause does not work like that. This query: select Notes as [Adres] from CaseActionHistory where ... UNION ALL select Info as [Numer] from CaseActionHistory where ... UNION ALL select Notes as [Mail] from CaseActionHistory where ... UNION ALL select Description as [Powód] from CaseActionDefinition join CaseActionHistory ... will not populate a table with 4 columns. Instead it will be a table with one column, with all the values one after the other. The name of the column will be taken from the first SELECT, i.e. if the first query returns values 1 and 2, the second query returns values 3 and 4 the third query returns values 5 and 6 the fourth query returns values 7 and 8 you wont get: Adres | Numer | Mail | Powód ------------------------------ 1 | 3 | 5 |

Categories : SQL



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.