w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
SQL Server Subquery returned more than 1 value. the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
Ok, if I'm not wrong, you are getting your error code here declare @RefWeapon int = (Select top 1 ID from SRO_VT_SHARD.dbo._RefObjCommon WITH (Nolock) where Service = 1 AND TypeID1=3 AND --- Weapon TypeID2=1 AND TypeID3=@WeaponType3 AND TypeID4=@WeaponType4 Group by SRO_VT_SHARD.dbo._RefObjCommon.ID,SRO_VT_SHARD.dbo._RefObjCommon.reqlevel1 having (MAX(ReqLevel1)<=(Select CurLevel from SRO_VT_SHARD.dbo._Char where charid = @CharID)) Order By ReqLevel1 Desc ) specially in this part having (MAX(ReqLevel1)<=(Select CurLevel from SRO_VT_SHARD.dbo._Char where charid = @CharID)) Why? Ok, MAX(ReqLevel1) is 1 v

Categories : SQL

Does 'select distinct' returns the first distinct value or last distinct?
I think there's a misunderstanding here: Your query does not return the records, only the distinct column values. Which, in your example, are 'Sam' and 'Tom'. They have no particular order which can safely be expected. It may be the natural order, or the order in which they are processed on the database (completely depending on the database implementation), or semi-random (such as iterating over items in a set). The order may also vary depending on whether the result was retreived from the data or from the cache. If you want a particular order, then specify it as order criterium: select distinct Name from Emp order by Name asc If you want the distinct values and the first record containing it, use group by: select min(ID), Name from Emp group by Name

Categories : SQL

Overhead of saving results of a MySQL subquery into TEMPORARY TABLE (as opposed to duplicating the subquery)?
I think it depends a lot on version of mysql, so you may want to consider restricting which versions of mysql your reporting library will work on (if you haven't already). My general understanding is MySQL subqueries are BAD and that conversion to actual joins or utilising a temp table is almost always better - unless the temp table gets pushed to disk! I would read the documentation mysql provide as a good starting point on the latest info: dev.mysql.com/doc/internals/en/transformations.html and dev.mysql.com/doc/refman/5.5/en/optimizing-subqueries.html

Categories : Mysql

query with subquery and testing boolean result of this subquery fails
Try execute separately SELECT CDCREDITEUR FROM GROOTBOEKMUTATIES WHERE GROOTBOEKMUTATIES.BOEKJAAR = 2013 and SELECT CDCREDITEUR FROM CREDOPENPST WHERE CREDOPENPST.BOEKJAAR = 2013 And see what result it returns

Categories : SQL

How to use a subquery inside another subquery with three tables in mysql?
GROUP_CONCAT will return a string but the IN operator works with a set of values and not with a string so you have to use something like this SELECT u.uid, u.fname, u.date_joined , (SELECT COUNT(*) FROM questions WHERE questions.uid = u.uid) AS question_count, (SELECT COUNT(*) FROM followers WHERE followers.qid IN ( SELECT qid FROM questions WHERE questions.uid = u.uid ) ) AS follow_count FROM users AS u ORDER BY follow_count DESC, question_count DESC, date_joined DESC fiddle: http://sqlfiddle.com/#!2/8cd10/2

Categories : Mysql

SQL Insert rows into table that must have 2 distinct columns but also one non distinct column
You'll have to just replace the PRIZEID value with new ones. Because it sounds like you currently have duplicates on your PROMOTION table First add all the distinct PRIZENAMEs and COSTs to your new PRIZE table: INSERT INTO prize(PRIZEID, COST, PRIZENAME) SELECT DISTINCT (SELECT MAX(PRIZEID)+1 FROM PRIZE), r.COST, r.PRIZENAME FROM PROMOTION r; Then update your PROMOTIONs table with the new PRIZEID UPDATE PROMOTION R SET R.PRIZEID = (SELECT P.PRIZEID FROM PRIZE WHERE P.PRIZENAME=R.PRIZENAME AND P.COST=R.COST); Then, I think from there you can safely delete the columns from your PROMOTIONs table

Categories : SQL

Distributing k distinct items among r distinct groups without ordering
The solution is Stirling's Number of the Second Kind * r! So that's: 1/r! * (SUMMATION(j=0 --> r), (-1)^(r-j) * C(r,j) * j^k) * r! Which simplifies to: (SUMMATION(j=0 --> r), (-1)^(r-j) * C(r,j) * j^r)

Categories : Misc

MSQL select regardless of distinct or not distinct (count greater than zero)
In the data in the question, there is no repeating id in table A. The query should be returning only one row from A, then. However, your query has an error. The second join should be back to the first table, not the second: SELECT a.col1, b.col1, c.col2 FROM a LEFT JOIN b ON b.id = a.id LEFT JOIN c ON c.id = a.id WHERE a.id = 1 You had c.id = b.id and b.id could be NULL if there is no match in that table. Also, from your description, I wonder if a union would be the best approach: select a.col1, 'a' from a where id = 1 union all select b.col1, 'b' from b where id = 1 union all select c.col2, 'c' from c where id = 1

Categories : Mysql

Aggregate String[] grabbing first distinct, but I want it to grab the last distinct
Consider using the overload of Select that takes in the index as part of the transformation (documented here). If you want the last distinct element of each distinct element, you might try to use GroupBy order each IGrouping accordingly, and grabbing the correct element of each group. repeat = domain + dir.Split('/') .Select((word, index) => Tuple.Create(word, index)) .Where(x => keep.Contains(x.Item1)) .GroupBy(x => x.Item1) .Select(g => g.OrderByDescending(x => x.Item2).First()) .OrderBy(x => x.Item2) .Select(x => x.Item1) .Aggregate((gi, j) => gi + "/" + j) + repeat.Substring(lastSlash); Here, we couple each word with its index (using the Select overload mentioned above). Then we filter down to the words of interest. Instead of using Distinct, we now use

Categories : C#

Difference between Subquery and Correlated Subquery
Correlated Subquery is a sub-query that uses values from the outer query. In this case the inner query has to be executed for every row of outer query. See example here http://en.wikipedia.org/wiki/Correlated_subquery Simple subquery doesn't use values from the outer query and is being calculated only once: SELECT id, first_name FROM student_details WHERE id IN (SELECT student_id FROM student_subjects WHERE subject= 'Science');

Categories : SQL

"Subquery returned more than 1 value" for SELECT subquery
It depends on what you expect to appear in the single column if more than one row is returned? If you want the total of charges, use SUM() around your multiple-row-returning subquery: SELECT DISTINCT FH.ShipDate, AVG(FH.[Dist Freight]) AS [Atlantic Freight Charge], SUM(SELECT DISTINCT [Non-Atlantic Freight Charge] FROM (SELECT DISTINCT FH.ShipDate, AVG(FH.[Dist Freight]) AS [Non-Atlantic Freight Charge] FROM dbo.vw_FreightHistory AS FH WHERE VendorName != 'Atlantic Trucking' GROUP BY ShipDate, VendorName) AS [Non-Atlantic Freight Charge])) FROM dbo.vw_FreightHistory as FH WHERE VendorName = 'Atlantic Trucking' GROUP BY ShipDate, VendorName ORDER BY ShipDate

Categories : SQL

Select distinct values of distinct group
You can use the following code to get your desired array with only 1 SQL executed $sql = "SELECT title, group_concat(year) as years FROM table_name group by title" $rs = mysql_query($sql); $arr = array(); while($row = mysql_fetch_assoc($rs)) { $arr[$row['title']] = explode(',',$row['years']); }

Categories : PHP

Join Distinct Id on non-distinct id (MySql)
SELECT t.ID, t.val_string, t.val_int, t.val_datetime FROM table1 AS t LEFT JOIN (subquery) AS v_table ON t.ID = v_table.ID Sample fiddle

Categories : Mysql

IQueryable.Distinct() vs List.Distinct()
Obviously you cannot have exact duplicate rows (including the primary key) in your table. Probably what you mean is rows with some equal fields (excluding primary key). Calling Distinct on IQueryable, generates a SQL DISTINCT operator on the resulting query, which compares every field of your table against each other. Because you cannot have exact duplicate rows in the table, it returns all the rows. On the other hand, calling Distinct on a List<User> will use Equals method of the User object to compare objects in memory (after fetching all the rows from database). The final result depends on the implementation of Equals method, which could check only some fields for equal values.

Categories : C#

Distinct value of a column and do a count on each distinct value
Considering the following example: To get the unique values, and the occurrences of each unique value, you can do the following: The image is tiny, so here is are the formulas to type-in and drag down: FORMULAS 1. Type in the first cell of column B: =IF(ISERROR(INDEX($A$2:$A$8,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$8),0,0),0))),"",INDEX($A$2:$A$8,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$8),0,0),0))) Drag the formula down the column B. You will get a list of unique values. 2. Type in the first cell of column C: =COUNTIF($A$2:$A$8,B2) Drag the formula down the column C. You will get the number of occurrences of each unique value. RESULT This is what you will get:

Categories : Excel

select distinct out of distinct
The easiest way is to do aggreagtion: select etar.EmplKey, min(emp.EmplFullName) FROM EmployeeTarget etar inner join DimEmployee emp on emp.emplkey = etar.emplkey inner join dimbranch br on br.BranchId = etar.BranchId where etar.BranchId = 8 group by etar.EmplKey

Categories : SQL

Advice on using GitHub
Your idea works fine, it sounds like you are just inexperienced with git. There are many tutorials available online, it takes a little getting used to. The issue you may be encountering is a git pull will bark at you if you have uncommitted changes locally when trying to pull. Make sure you have a clean, committed state when you pull and it'll work. Also, if you have committed but un-pushed changes, a pull will try to merge those changes, since that's what you asked it to do. Often this won't really be a problem, but conflicts can happen, and you'll need to resolve them when it does. This is just a normal occurrence with version control and something you should get used to dealing with.

Categories : GIT

C++: design advice
First advice is not to use protected atributes. Is is breaking incapsulation. The second advice is to make virtual void f()=0 pure virtual without implementation. In such there will be no error in the derived class.

Categories : C++

Advice on CSS Positioning
I'd try to give some width to my divs. If your entire page is 800 px then; .page{your stuff} .top-div{width:800px; float:left; margin:0 auto;} .logo{float:left; width:200px;margin:0 auto;} .toparea{float:left; width:600px; margin:0 auto; } .sidebar{float:left; width:200px; margin:0 auto;} .mainpart{float:left; width:600px; margin:0 auto;} .bottompart{float:left; width:800px; margin:0 auto;} Imagine css as lego. if you put something on your 4 block size logo, it should stay there perfectly, if not check the size or your alignments. edit: this is not a solution, just a hint to give you idea about what to do.

Categories : CSS

Set a variable from an AOP advice
I don't know if it's the right way to do it, so feel free to comment. I created an interface Authed and its implementation AuthedImpl. public interface Authed { void setOwner(Owner owner); } Then I made RealEstatePropertyV1 extends from AuthedImpl. I added a pointcut for all classes extending from AuthedImpl and also changed the pointcut so I can access to the target. @Pointcut("execution(* *..AuthedImpl+.*(..))") public void extendsAuthedImpl() { } @Pointcut("execution(* *.*(.., com.google.appengine.api.users.User)) && args(.., user) && target(callee)") public void allMethodsWithUserParameter(User user, Authed callee) { } Finally the advice uses all pointcuts: @Before("annotatedWithApiMethod() && allMethodsWithUserParameter(user, callee) && exte

Categories : Misc

asp.net cache advice
But.. how you can do it for a single row of the table.. In ASP.Net you can create SQl Server dependency which uses a broker Service.. and puts the data into the cache and whenever the table is updated.. the cache will be rejected and new data is taken from db and put into the cache.. i Hope this might give you some idea!

Categories : Asp Net

Python 2,7 Dictionary Advice
Use a list as value, list will allow you to append new items: >>> dic = {'PhysicalDrive0': ['0', '1', '2'], 'PhysicalDrive1': ['0', '1']} >>> dic['PhysicalDrive0'].append('3') >>> dic['PhysicalDrive1'].append('2') >>> dic {'PhysicalDrive1': ['0', '1', '2'], 'PhysicalDrive0': ['0', '1', '2', '3']} To append to a value to a missing key you can use dict.setdefault, if the key is already present then it'll append value to the already present list otherwise creates a key with an empty list and then appends the value to it. Demo: #creates a new key PhysicalDrive3' and appends a value to it. >>> dic.setdefault('PhysicalDrive3', []).append('3') >>> dic {'PhysicalDrive1': ['0', '1', '2'], 'PhysicalDrive0': ['0', '1', '2', '3'], 'PhysicalDri

Categories : Python

Give advice for php xls eporter
I am using this one : https://www.manjeshojha.com/how-to-import-the-excel-data-in-mysql-database-using-php-script/ Working fine for me..Try tour self once..

Categories : PHP

Code optimization advice
When you created that code, you had to do a lot of cutting & pasting, right? You got one if statement that worked, and then cut & pasted it, and changed the text, and kept doing that 19 times. And boy did that suck, didn't it? What you want to do when you are doing the same thing over and over again is do it in a loop. In your case, you need an array of information about each of the possible ranks, and then you repeatedly do your substr check (which might not be the best way to do it, but we'll let it be for now), and then set your return variables accordingly. $a = get_the_excerpt(); $rank_list = Array( Array( 'Gen', 'General', 'Gen.png' ), Array( 'Col', 'Colonel', 'Col.png' ), // And so on... Array( 'PFC', 'Private First Class', '' ), Array( 'Pvt', 'Priva

Categories : Wordpress

Need some advice on C header inclusion
Everything you've described seems like the normal way to do things. Your two compilation units are only getting the same forward declarations of functions in those headers, not actual duplicate definitions from the libraries. My question is though, is the linker clever enough to only put these declarations in the executable file once? The linker certainly doesn't care what header files you include - it's a linker, not a compiler. So that even though I include these headers several places, it won't have any effect on file size and such? Extra/unused forward declarations of functions will have no effect on binary size. And is this even the correct way of handling common dependencies between several source files? Yes, you seem to be doing things in a completely normal way.

Categories : C

Advice on where to import app.less in boostrap 3.0?
Why not make an additional LESS file that calls both your custom file and Bootstrap's. So within mystyles.less you will have @import "bootstrap.less"; @import "app.less"; Then when there is a newer version of Bootstrap, you will just replace files, keeping your file untouched.

Categories : Twitter

Need some advice on regex in Sigil
I am not sure what you want. the href value for <a> ? if so ,you can try this: (?i)(?<=<a[^>]*?href=(['"]?))[^'"]*?_ftnd+[^'"]+(?=1)

Categories : Regex

ArrayAdapter Advice or Suggestions
Once u have the Predictions rather than passing it pass create arraylist based on result. Code: ArrayList<String> al= new Arraylist<String>(); if (predictions.size() > 0 && predictions.get(0).score > 1.0) { String result = predictions.get(0).name; if ("A".equalsIgnoreCase(result)) { al.add(result); Toast.makeText(this, "A", Toast.LENGTH_SHORT).show(); } adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, al); edittext.setAdapter(adapter);

Categories : Android

Advice on image storing
You're probably going to want to see what YouTube has to say on the matter; I'm sure it's got something regarding this in its developer API documentation to note their preferred approach to it. That said, take this as general advice; when you're constantly querying another system, you generally want to limit how annoying you are. Now, YouTube's not going to notice the load of one app, of course, but it's still a good habit to keep. Generally speaking, I'd prefer to split the difference: cache the image based on video ID and hold it for X hours, so if the user pulls up the same video in a search 20 times you didn't request a thumbnail 20 times as well. That way you keep the result relevant by updating the image every day or two (assuming they searched for the video again). Edit: Right, a

Categories : C#

VB.net + mySQL + md5 hashing advice
While I'm not familiar with how salts are supposed to work, I've created a function that hashes a password and a salt, then uses them as input to create the final hash. You'll need these: Imports System.Security.Cryptography Imports System.Text Imports System.IO To run this: Private Function CreateMD5(password As String, salt As String) As String Dim passwordBytes() As Byte = Encoding.UTF8.GetBytes(password) Dim saltBytes() As Byte = Encoding.UTF8.GetBytes(salt) Dim saltedPasswordHash As Byte() Dim md5Hasher As MD5 = Security.Cryptography.MD5.Create() Dim buffer As New MemoryStream Dim writer As New StreamWriter(buffer) With {.AutoFlush = True} Try writer.Write(md5Hasher.ComputeHash(passwordBytes)) writer.Write(md5Hasher.ComputeHash(saltBy

Categories : PHP

Azure configuration advice
For your database, you'll want to run SQL Server in a Virtual Machine, as you'll then get all functionality of SQL Server, including FTS. It's very simple to get up and running with SQL Server VM's, as there's a gallery image with SQL Server preinstalled. Regarding your file system storage: This won't scale to multiple instances. You'll need another mechanism for storage. Typically this would be Blob Storage, but... it depends on what you're doing with the files. If you're just serving / storing content (you mentioned uploaded content), this works great, and it's accessible across many instances. If, on the other hand, it's some type of file-based database or index, that won't really work well. If you need to do some type of local processing on the files (e.g. photo or movie rendering),

Categories : Azure

Advice on sql naming conventions
Lookup ISO-11179 for the international database naming standard. for this you can grab this online for free download (though sorry I forget where). There is a lot in it, so here are some some basic summary form it: Take your field description, remove joining words and write it backwards. Always end with a class name. There are standard abbreviations like ID for identifier and such. eg: Date of Entry: Entry_Date Seconds_For_Delivery: Delivery_Seconds Name of Widget: Widget_Name Location of Widget: Widget_Location Size of Widget: Widget_Size Also a field should have the same name if it is a primary key or a referenced foreign key. This will pay off in readability for people that come after you, and also most DB tools will assume they are matching keys so you will a

Categories : SQL

Advice on serialization for a game
Yes, serialVersionUid is intended to be a hash or version that exactly identifies which version of the Serializable class, the data was output by. Unfortunately it mainly acts as an impediment to serialization -- by causing every minor change to break serialization. Any different version will cause an exception to throw. Recommended practice is to generate or assign a serialVersionUid constant in your java source, to avoid unnecessary incompatibility. From the Javadoc: To guarantee a consistent serialVersionUID value across different java compiler implementations, a serializable class must declare an explicit serialVersionUID value. If you dig into the Java source you may be able to find methods to implement/override, which can give you more control over serialization. See:

Categories : Java

Advice with for loop programs
You're generating the random number outside of your loop. Therefore it will exist as the same number every time. The solution is to move the definition inside of the loop. public static void main(String[] args) { for(int counter = 0; counter < 30; counter++){ int random = (int) (Math.random() *50) +25; System.out.println(random); } } In this way, every time through the loop (30 iterations), your code will (1) generate some random number and (2) print that number.

Categories : Java

Advice on Emberjs usage
When you say that Ember can provide single page app, does that mean we are not using rails views any more? what is the connection between both of the views? I am confused about this issue so far. Yes that is what it means. Our ember app has one rails view but it's nothing but a head/body tag. Having Rails as the JSON API, does that mean we neglected other powerful features like haml processing and other views based technologies? Yes but you don't get points for using the most technologies. Tech like HAML is designed for writing a rails-style MVC app. Handlebars is a better choice for an ember app. For Model validations, is Ember models are different from Rails Models, how can we integrate both? They are different and that is a good thing. In a simple app there is often a

Categories : Ruby On Rails

Spring AOP advice is not getting called
You need to read the documentation about proxies here. Basically, because of the way proxies are generated, a instance method call within another instance method will not trigger an aspect (or proxy behavior). Given: class FooBar { // advised method public void foo() { bar(); } // would've been advised public void bar() { // ... do something } } Say an instance of FooBar was proxied, a call to foo() will trigger the aspect because from outside you have a reference to the proxy object. When you call bar() internally, you have access to this (equivalent to this.bar()) which is a reference to the target instance, the actual object, so there is no added behavior. There are a few ways to solve this problem, but probably not the way you want. See th

Categories : Java

Website layout advice
Could you not just give the divs a max or min height depending on their purpose? I use a main container or wrapper div that the others would be contained in, that div is then my effective page or screen area. <div id="wrapper"> <div id="content"> <div id="sidebar"> </div> </div> </div> #wrapper{ min-height: Whatever value you want here; max-height: Whatever value you want here; } It might be a good idea to set up your page using main container divs, hot only for the content but for the header and footer as well. As an example, I have a main wrapper that is the whole page, within that is the header div, the content div, the nav div and the footer div. These are the main ones. Everything else can then be contained w

Categories : HTML

Need Some Advice on HTML Forms
I'm pretty sure that you shouldn't be using parameters in your ORDER BY clause. If it were me I would implement an ObjectDataSource and create my ORDER BY clause dynamically using server-side hard-coded alternatives. If you go down that route, then make sure to ALWAYS USE PARAMETERS FOR USER-SUBMITTED DATA TO SECURE YOURSELF AGAINST SQL INJECTION ATTACKS. If you're not up to tackling the ObjectDataSource class, then consider implementing a different SQLDataSource for each of your sort options. Each one will implement a different ORDER BY clause. Set the DataSourceID based on the value of the query parameter. Not sure if that works as-is. You may have to set your GridView's DataSource explicitly. If so, remember to call Databind() explicitly too.

Categories : C#

Advice on SQL structure and maybe JOIN?
You could add a user_id column to your fish table like you said. When a user registers a fish, you'd have to insert his user_id at the same time. I suppose you use sessions to keep the users logged in, so you should have a session variable containing the user id.

Categories : PHP

Advice for POUR1 on SPOJ?
Consider the set of all a priori possibles states (eg [3, 7] meaning Vessel1 contains 3 litters and vessel2 contains 7 litters). You have a directed graph whose vertices are those states and whose edges are the possible moves. The question is to find a path in the graph joining the state [0, 0] to either a state of type [c, ?] or a state of type [?, c]. Such a path is typically searched by a BFS.

Categories : C++



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