dimanche 26 juin 2016

Distinct not working as expected with sql

How does distinct work with the following table:

id  | id2    | time
-------------------
1   | 5555 | 12
2   | 5555 | 12
3   | 5555 | 33
4   | 9999 | 44
5   | 9999 | 44
6   | 5555 | 33

select distinct * from table

SQL Server sp_columns does not return result

I was trying to check the data types of each column. I have tried the code below. use AdventureWorks2014 exec sp_columns Person; However, the result return something like this. PS: I am using AdventureWorks sample database.

MySQL pivot data

I have data. A, STATUS, P A1, 1, P1 A1, 1, P2 A1, 1, P3 A2, 1, P3 A2, 1, P4 A2, 1, P5 A3, 0, NULL I want result same P, A1, A2, A3 P1, 1, 0, 0 P2, 1, 0, 0 P3, 1, 1, 0 P4, 0, 1, 0 P5, 0, 1, 0 How can I do it with mysql query?

Image upload path in MAC style instead of Windows style PHP Ecommerce

I have issues with uploading pictures on my local development environment[enter image description here][1] XAMPP, [What is shows when i use inspection tool to check the directory instead c//; ecom/resources/upload/name of image i get c/recource/enter image description hereuploadname of image Function to addproduct

How to select a particular row of query result

I have a following table in my Oracle database: How can I select the course which is done by most of the students? I am trying multiple variations in following SQL query but it's not working - select count(course) as pcourse, course from studies group by course order by pcourse dec;

SQL Error - has more columns than were specified in the column list

I'm trying to retrieve results from the below query but keep getting this error message: Msg 8158, Level 16, State 1, Line 1 'a' has more columns than were specified in the column list. My query: select * from (select customer_key as customer_id, updated_by as [Help Desk] from permission) a (nolock) where [Help Desk] is not null

Update table1 column if table2.date > NOW()

How can i update specific column in table1 only when table2.date is >= NOW(). I tried

UPDATE table1 JOIN table2 ON (table1.ownerid = table2.ownerid) SET table.test = 'disabled' WHERE FROM_UNIXTIME(table2.dateto) <= NOW();

But its seems to now work and no error at all