[Solved] Oracle Sql Statement for unique timestamp for each row

The following UPDATE statement will guarantee that each row has a unique MY_TIMESTAMP value, by increasing the milliseconds by the rownum value. EDIT: After Alessandro Rossi pointed out that there could be duplicate values, the following query has been modified to use SYSTIMESTAMP for the update. UPDATE ITEM_HISTORY SET my_timestamp = SYSTIMESTAMP + NUMTODSINTERVAL(rownum/1000, ‘SECOND’); … Read more

[Solved] PHP SQL / Duplicate entries

Create a unique index on Col A and Col B: MySQL: ALTER TABLE `mytable` ADD UNIQUE `unique_index`(`ColA`, `ColB`); ANSI SQL example: ALTER TABLE mytable ADD CONSTRAINT unique_index UNIQUE (ColA,ColB); 2 solved PHP SQL / Duplicate entries

[Solved] How to group rows with same value in sql? [closed]

Try this DECLARE @temp TABLE(col1 varchar(20),col2 int, col3 varchar(20)) insert into @temp values (‘data1′, 123 , ’12/03/2009’),(‘data1′, 124 , ’15/09/2009’), (‘data2 ‘,333 ,’02/09/2010’),(‘data2 ‘,323 , ’02/11/2010’), (‘data2 ‘,673 , ’02/09/2014’),(‘data2′,444 , ’05/01/2010’) SELECT (CASE rno WHEN 1 THEN col1 ELSE ” END )AS col1, col2, col3 FROM ( SELECT ROW_NUMBER() OVER(PARTITION BY Col1 ORDER BY … Read more

[Solved] How to Update one column (point) in php sql [duplicate]

It is very easy… $con = mysql_connect(“servername”,”username”,”password”); mysql_select_db(“databasename”); $command = “UPDATE tuser SET point=”your value” where id=whatever”; //replace ‘your value’ with the new value and “whatever” with the user id mysql_query($command); mysql_close_connection($con); Next time don’t ask so stupid questions here… use Google solved How to Update one column (point) in php sql [duplicate]

[Solved] self check database [closed]

It sounds like you are approaching the problem from the wrong perspective and over complicating it. How do the ID’s get into the database? You should go to that point in the code and log it and/or notify yourself at that point. For example, if you want to be notified each time a user signs … Read more

[Solved] How to show the query inside PHP? [closed]

Maybe you want something like this (example with mysql): $conection = mysql_connect (“localhost”,”root”,””) or die(“Can’t connect to the database”); mysql_select_db(“database name”) or die (“Can’t connect to the database”); $sel=”SELECT SUM( value ) FROM table_name WHERE field_id IN ( 31, 33, 35, 37, 39, 41 )”; $query = mysql_query($select,$conexion) or die (“Bad.”); $row=mysql_fetch_array($query); Now, $row is … Read more

[Solved] updating values in one table from another table using DYNAMIC SQL in MSSQL

Try following query: UPDATE TableB SET [1] = ISNULL(z.[1],TableB.[1]), [2] = ISNULL(z.[2],TableB.[2]), [3] = ISNULL(z.[3],TableB.[3]), [4] = ISNULL(z.[4],TableB.[4]), [5] = ISNULL(z.[5],TableB.[5]), [6] = ISNULL(z.[6],TableB.[6]), [7] = ISNULL(z.[7],TableB.[7]) FROM ( SELECT [1],[2],[3],[4],[5],[6],[7] FROM (SELECT Id, Value FROM TableA)AS p PIVOT (MAX(Value) FOR Id IN([1],[2],[3],[4],[5],[6],[7]))AS pvt )z EDIT In order to have dynamic pivot use following query: … Read more

[Solved] get quarter of current date in sql server 2008 [closed]

You can use datepart if you have quarters specified as 1,2,3 and 4 as: declare @date date = getdate() select case when datepart(MM, @date) IN (4,5,6) then ‘Q1’ when datepart(MM, @date) IN (7,8,9) then ‘Q2’ when datepart(MM, @date) IN (10,11,12) then ‘Q3’ when datepart(MM, @date) IN (1,2,3) then ‘Q4’ end as Quater solved get quarter … Read more

[Solved] Find string according to words count

A) Use String_Split or something similar to create a table for each word. LG 55 Vacuum theater home #table_of_words (text varchar(32)) text LG 55 Vacuum Theater Home B) join the created table with the main table using an expression like SELECT DISTINCT Description FROM main_table Main JOIN #table_of_words WD ON Main.Description Like ‘%’+WD.text+’%’ If you … Read more

[Solved] MYSQL Select group by order by

To get the most recent row of data by sender and receiver, you can use a self join as follows: select * from messages msg where sent = (select max(sent) from messages msg_ where msg_.fromperson = msg.fromperson and msg_.toperson = msg.toperson) See how it works in this Fiddle 0 solved MYSQL Select group by order … Read more

[Solved] SQLZOO Nobel Tutorial #8

All, I got it solved by myself. select distinct yr from nobel where subject=”Physics” and yr not in (select distinct yr from nobel where subject=”Chemistry”) Thanks I also find a way to reveal the answer of those questions(at least some of them) just append ?answer=1 to the url, you may be able to get an … Read more