w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
selecting distinct record using sql
SELECT PJ.* FROM People_Job PJ INNER JOIN ( SELECT People_ID, MAX(ID) MAX_ID FROM People_Job GROUP BY People_ID ) T ON PJ.People_ID = T.People_ID AND PJ.ID = T.MAX_ID

Categories : Sql Server

How to SELECT the last distinct record in SQL SERVER
Try like this..... Select Cod,Id,Balance,[Date] from ( Select Row_Number() Over(Partition By Cod,Id Order By [Date] desc) as Row, Cod,Id,Balance,Date from table) t where t.Row=1

Categories : Sql Server

Finding the distinct record from sql server
try something like this WITH MD_Results AS ( SELECT P.pk, P.procedure_name, RowNum() OVER (PARTITION BY P.procedure_name order by P.procedure_name asc) AS RowNum FROM "procedure" P, "procedure_user_map" PUM where P.pk = PUM.procedure_fk ) SELECT top 10 pk, procedure_name, RowNum FROM MD_Results WHERE RowNum > 1

Categories : SQL

SQL: Display Distinct Record From A Column
I think select distinct * from <your table> will work for you In your case with different times, you could use: select distinct LogID, OrderNo, cast(MaxDate as date) as MaxDate, AnotherDate, Status from <your table>

Categories : SQL

Distinct record using linq in entity framework
var query = (from c in CompObj.EmpInfoes join d in CompObj.Leaves on c.EmpID equals d.ProjectManagerID where c.RoleID == 4 || c.RoleID == 2 select new { c.EmpName, c.EmpID }) .Distinct(); Or was there something more you needed?

Categories : C#

MySQL: How to fetch all columns with distinct clause on one column with latest created record
Limit can be used in mysql to achieve this. SELECT DISTINCT deviceID, createdDate FROM `devicePosition` ORDER BY createdDate desc limit 1 Also, you can where clause SELECT DISTINCT deviceID, createdDate FROM `devicePosition` WHERE createdDate = (select max(createdDate) from `devicePosition`)

Categories : Mysql

On key up Ajax function for checking if name exist returns multiple identical values despite using codeigniter active record distinct query
Try adding some checks before setting a new timeout to prevent multiple triggers to your ajax call var typingTimer = null; var doneTypingInterval = 3000; $('#course_name').keyup(function () { if (!typingTimer) { typingTimer = setTimeout(check_course_name_exist, doneTypingInterval); } }); $('#course_name').keydown(function () { if (typingTimer) { clearTimeout(typingTimer); typingTimer = null; } });

Categories : Javascript

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

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

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#

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

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

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

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

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#

How To Assign an Existing Record to Another Record in Active Record
According to your models your Host must have a student_id. It's unclear from your example, but it seems like your student_id in Host.first is not Student.last.id. Another point which was touched on a bit by @kobaltz comment is that your Post model has the host_id and student_id. This looks like you are using it as an association. So your model should probably look like this. post.rb belongs_to :host belongs_to :student student.rb has_many :posts has_many :hosts, :through => :posts host.rb has_many :posts has_many :students, :through => :posts

Categories : Ruby On Rails

Flowplayer question mark
A question mark URL encodes as %3F. But you should use a proper encoder for the whole thing rather than manually encoding a specific character. Depending on the server-side technology you're using to build the Urls, tyhere should be a function like UrlEncode() which should handle all this for you. Failing that, Javascript has encodeUriComponent()

Categories : Misc

How to match a question mark?
Use quotemeta for the regex pattern. use warnings; use strict; my $search = quotemeta 'http://shorturl.com/detail.cfm?color=blue'; my $replace = 'http://shorturl.com/detaila.aspx?color=red'; my $file = '<a href="http://shorturl.com/detail.cfm?color=blue" class="news">HI</a>'; $file =~ s/$search/$replace/gis; print $file; __END__ <a href="http://shorturl.com/detaila.aspx?color=red" class="news">HI</a>

Categories : Regex

C++ spanish question mark
this character is simply not included in basic ascii. Try using wstring http://www.cplusplus.com/reference/string/wstring/

Categories : C++

MySQL - question marks
Your database table column should be created with proper charset and collation. You can define theit while creating or altering a table: col_name {CHAR | VARCHAR | TEXT} (col_length) [CHARACTER SET charset_name] [COLLATE collation_name] Here is the mysql link to help you learn more about it: http://dev.mysql.com/doc/refman/5.0/en/charset-column.html

Categories : Java

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

"You cannot add or change a record because a related record is required", but related record exists?
Both tables include a text field named LanID. You are using that field in this relationship, which enforces referential integrity: The problem you're facing is due to the Lookup field properties. This is the Row Source: SELECT [LanID].ID, [LanID].LanID FROM LanID ORDER BY [LanID]; But the value which gets stored (the Bound Column property) is the first column from that SELECT statement, which is the Long Integer [LanID].ID. So that number will not satisfy the relationship, which requires results.LanID = [LanID].LanID. You must change the relationship or change the Lookup properties so both reference the same field value. But if it were me, I would just eliminate the Lookup on the grounds that simple operations (such as this) become unnecessarily confusing when Lookup fields

Categories : Ms Access

What may cause question marks instead of non-ASCII symbols?
You need to change the character set of the database to UTF-8 or a character set for Cyrillic characters. Latin-1 can't encode Cyrillic characters and that's why they're appearing as question marks in the database. edit: I just saw you're declaring the table with UTF-8 character set, so I'm stumped.

Categories : PHP

.htaccess rewrite URL with a question mark "?"
RewriteRule ^component/users/?view=registration$ registration.html$ [R=301,L] You need a because ? is part of a regular expression. To Use it as a string u need to escape it with a Linktip: http://ole.michelsen.dk/tools/regex.html

Categories : Htaccess

Check if last character is a question mark
if (substr(rtrim($link), -1) != "?") { // Do stuff } Giving a negative start value to substr() makes it count from the end instead of the beginning.

Categories : PHP

R - how does the "question mark" function works?
You can make functions and variables with arbitrary names, via use of the backtick `. `~` <- `+` y <- 5 x <- 10 y ~ x # 15 I wouldn't mess with ~ though, unless you don't intend to do any statistical modelling....

Categories : R

URLRewrite rule for a URL that only contains one value after the question mark
Try this code. Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{QUERY_STRING} ^([a-z0-9-]+)$ [NC] RewriteRule ^$ /#!/videos:%1? [L,R=301,NE]

Categories : Htaccess

How to remove question mark in a JOptionPane?
Use the PLAIN_MESSAGE message type JOptionPane.showConfirmDialog(null, "Help", "Please Enter X and Y Values", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);

Categories : Java

Can't read a file that contains a question mark in name
As long as the file exists, there is no problem opening a file like this: folder_file = './temp directory/file-?.txt' File.open(folder_file, 'r').close This works fine. See Tin Man's suggestion about how to actually open the .tif file. As you can see, I created the following file myster-file_char?.txt $: ls get_listing.rb myster-file_char?.txt You can get this stored in a variable, though I only use Dir.glob here to view it. puts Dir.glob("**.*").inspect Everything is now revealed in what character it is. Though I should be able to use it directly as is to open and edit the file in Ruby. Though like The Tin Man stated, you are asking about a binary file. $: ruby get_listing.rb ["myster-file_charu0016.txt", "get_listing.rb"] The character that is actually there is a CTRL

Categories : Ruby

mod rewrite question mark and ampersands
I think the issue here is that in your RewriteRule you're trying to match a part of the query string, which isn't possible. If I understand your problem correctly, you want requests to http://example.com/category/general?type=pages&v=1 to be interpreted by the server as http://example.com/category.php?c=general&type=pages&query=1? To match a query string, you need to prefix your rule with a condition. The following should work: RewriteCond %{QUERY_STRING} type=([^&]+) RewriteCond %{QUERY_STRING} v=([^&]+) RewriteRule ^category/([^/]+) /category.php?c=$1&type=%1&query=%2 The first two lines are pre-conditions that state that the requested URL needs to have both type= and v= as part of the query string. The final line rewrites the request. This means that

Categories : PHP

What to do with Question Marks in HTAccess Redirects
If it's a single link you want to change you don't need a htaccess rule for that you can just do a redirect. redirect 301 /wordpress/?p=250 http://www.othersite.com/blog If the URL parameter changes you can use this rule. RewriteEngine on RewriteRule ^wordpress/(.*) http://www.othersite.com/blog [R=301,QSA,NC,L] Note that when you use the QSA flag it will append the URL with the query parameter so if that's what you want the resulting URL will be. http://www.othersite.com/blog?p=250 Otherwise if you remove the QSA flag, then it will just redirect to this http://www.othersite.com/blog

Categories : String

hr content shows question mark
The probable explanation is that although the HTML document is declared to be UTF-8 encoded, it actually isn’t. It might be windows-1252 encoded, and when the windows-1252 encoded representation of “§” is encountered when processing presumed UTF-8 data, it constitutes a character data error. A common, and recommended, way in which browsers indicate the error is “�” REPLACEMENT CHARACTER. To fix this, make sure the declared and actual character encoding match. It is less relevant which encoding you use, but other things being equal, it is best to use UTF-8. So you would need an editor or other authoring tool that can actually save the data as UTF-8 encoded. If you absolutely cannot fix the encoding issue, replace "§" in CSS by the escape notation "A7". Much less readable, bu

Categories : HTML

Removing question mark ? from subfolder URL in htacces wp
How about something like this: RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /(.+)?( |$) RewriteRule ^(.*)$ /$1? [L,R=301] You'd put those rules in the htaccess file in your document root.

Categories : Htaccess

Can a Rails `where` query with question marks be done more elegantly?
Personally I will use a find by with a in condition such as: Klass.find_all_by_column([1, 2, 3]) Replace 'column' with column name you wish to search in. Replace 1,2,3 by your value, it's an array you can add or remove values from it. My example will generate a SQL query such as: SELECT * FROM Klass WHERE Klass.column IN (1,2,3) More on this on Active record documentation.

Categories : Ruby On Rails

PHP Regular expression: Get all urls with question mark
Don't try to make everything happen in one regex. Use your existing method, and then separately check the URL that you get back to see if it has a question mark in it. That said, don't use regular expressions to parse HTML. You cannot reliably parse HTML with regular expressions, and you will face sorrow and frustration down the road. As soon as the HTML changes from your expectations, your code will be broken. See http://htmlparsing.com/php for examples of how to properly parse HTML with PHP modules that have already been written, tested and debugged.

Categories : PHP

301 redirect with ? (question mark) not working in htacces
You can't match against the query string in a Redirect statement, use mod_rewrite and match against the %{QUERY_STRING} var: RewriteEngine On RewriteCond %{QUERY_STRING} ^AddID=1078&Rand=666171759380936096$ RewriteRule ^order/order.html$ http://www.domain.nl/? [L,R=301] But since you have like 8000 URLs that start with the query string ?AddID=, then you can just match against that: RewriteEngine On RewriteCond %{QUERY_STRING} ^AddID=[0-9] RewriteRule ^order/order.html$ http://www.domain.nl/? [L,R=301]

Categories : Htaccess

Getting Arabic Query String in Question Marks
Your Apache server probably doesn't accept UTF-8 URL encoding. See this answer to solve your problem. Hope it will help :)

Categories : PHP

What does the ? (backslash question mark) escape sequence mean?
? in regex is a quantifier, it means 0 or 1 occurences. When appended to the + or * quantifiers, it makes it "lazy". For example, applying the regex o? to the string foo? would match o. However, the regex o? in foo? would match o?, because it is searching for a literal question mark in the string, instead of an arbitrary quantifier. Applying the regex o*? to foo? would match oo. More info on quantifiers here.

Categories : Objective C

htaccess - regex - question mark in address
I have modified your regular expression. I hope that i have understood your challenge correctly. I have also provided a permalink to my test. Both of the URLs you provided in the comments passed. RewriteRule ^(.+)/article/(.+)/(.+).html(.*)$ index.php?content=article&id=$2&alias=$3 [L] Here is a link to my regular expression test.

Categories : Regex



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