samedi 27 juin 2015

What does this do? NVL (m-date), to-char(sysdate)

Hello im new to this site I have some questions to ask. Thank you.

What does this do? NVL (m-date), to-char(sysdate)

MySQL Case sensitive insert

I have created a database with case sensitive character set

Create database Grupo88 character set utf8 collate utf8_bin;

CREATE TABLE Grupo88.Usuarios(
    nombreUsuario varchar(30) primary key,
    clave varchar(120) not null);

INSERT INTO usuarios(nombreUsuario,clave)
       VALUES('guy','pass');
INSERT INTO usuario(nombreUsuario, clave)
       VALUES('Guy', 'password');

The first insert goes well, but the second one says that the value "Guy" already exists. Setting my database to be case sensitive is not enough? How can I do to allow case sensitive inserts?

Thanks

MYSQL limit returns unexpected results

<?php
$quuuu = mysql_query("SELECT * FROM products limit 9,15 ") or die("Query Error");
while($ffff=mysql_fetch_array($quuuu)){
    echo "<li><a href='view.php?id=" . $ffff['id'] . "'>" . $ffff['title'] . "</a></li>";
}
echo mysql_num_rows($quuuu);
?>

its should return (7), and the result is (15)

SQL JOIN to get two records for each row

I have two tables, say

TABLE: Transactions

COLUMNS: sender_id, receiver_id, value

and

TABLE: Users

COLUMNS: user_id, username

Is it possible to make a SQL statement to JOIN two rows from the users table for each record in the transactions table? So for each result row, I should have two usernames from the users table, but with two different aliases. How to achieve this?

Thanks

How do I add records from an Access database into an existing MSSQL database?

I have an existing Access database that has out grown it's usefulness. I have written a Visual Basic program that uses a SQL database and have been re-entering the data from the Access file into the SQL file individually. I still have 300+ records to move and would like to find a way to do all this using either a data snippet in Visual Basic, or using SQL Express. I'm smart enough to set up and use Access, and smart enough to Create a program and database in Visual Basic and SQL but for some reason I not smart enough to move the records between the 2 databases. When I originally created the .mdf file I attempted to move the records at that time but everything I tried didn't work so I figured I'd get it later, but now I have 300+ records in the .mdf file and need to get the others moved over. Anybody have any ideas?

Selecting max values of a column using the max value of another column

Hi folks I'm writing a query in MYSQL and it has challenged me. Here is the situation;

Let's assume I have a table named 'status' which keeps data for a tv show like that;

+---------+---------+---------+---------+
|   id    |  season | episode | channel |
+---------+---------+---------+---------+
|   1     |    2    |    10   |    a    |
|   1     |    3    |    2    |    b    |
|   1     |    2    |    9    |    c    |
|   1     |    3    |    1    |    d    |
|   1     |    3    |    2    |    e    |
+---------+---------+---------+---------+

I want to retrieve the rows which contains the last released episode of the last season. According to the table above, I expect a result like that

+---------+---------+---------+
|  season | episode | channel |
+---------+---------+---------+
|    3    |    2    |    b    |
|    3    |    2    |    e    |
+---------+---------+---------+ 

The max value of the season column is 3. In this case, I have retrieved the rows that have the max value of the episode column where season is equal to 3. I have written a query and it gives the expected result, but I don't think that it is an appropriate query. How could I improve the query below? If needed, I can add extra information or give further examples.

SELECT season, 
       episode, 
       channel 
FROM   `status` 
WHERE  `tvseriesid` = 1 
       AND `season` = (SELECT Max(season) AS Son 
                       FROM   `status` 
                       WHERE  `tvseriesid` = 1) 
       AND `episode` = (SELECT Max(episode) 
                        FROM   `status` 
                        WHERE  `tvseriesid` = 1 
                               AND `season` = (SELECT Max(season) AS Son 
                                               FROM   `status` 
                                               WHERE  `tvseriesid` = 1)) 

how do I create a user for internet and administration on MS SQL?

I am a knew to creating users on MS SQL. So Here is what I am trying to do.

I am a master user on the Database. I can create users and databases and whatever.

I want to create two more user

1) Administrator2: This user will execute all tasks or creating, dropping, modifying data, tables and procedures on the database. It would be the same as the db_owner, however this user CANNOT be able to drop the database. (My last admin dropped my database by mistake, I know not a very good admin).

2) WebUser: This user will be used by my application so it must be able to read, write, execute procedures, etc.

Is there a pre-made schema or something for me to achieve this? If not how can I achieve this?

I already know that I have to create Logins for the server access and users for the Database. But a good simple steps would be appreciated.