Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MYSQL


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Is There Any MySql Function Which Is Equalent To Oracle Last_Value Function


I am converting Oracle view to MySql where I am having the follwoing syntax in Oracle
last_value(col1 ignore nulls) over (partition by col2 order by col2, col3 rows between unbounded preceding and 1 preceding)

which I need to convert to MySql.




View Complete Forum Thread with Replies

Related Forum Messages:
IF Function,GROUP BY,aggregate Function Problems
Yep, I have all those problems in the title. So I'll explain each one at a time - I did have another thread relating to this very same query but I thought it was time to update where I am with the query because at the moment I feel like I am getting nowhere!

The query I have basically searches through an items_ordered table through each product and checks to see whether the item is VATable or not. This is not where I have the problem though. Where I am really having the first problem is when I am trying to use the IF function to check if the TOTAL of an order is over £300. IF it is then I multiply it my 0.95 (i.e. 5% off). With the query below I get no errors but neither do I get the desired result. It's as though it couldn't even see it. =....

View Replies !
Function In MYSQL
I am using MYSQL 5.0.22. My database name is 'normal'. It could contain 2 tables, such as Itemgroup & Itemlist. I tried with the FUNCTION query for Concatination purpose. Funtion name is Serial, The Query is,
CREATE FUNCTION Serial (s CHAR(10)) RETURNS CHAR(25) RETURN CONCAT('SALES',s,'IND');
It would say the error as followes,
ERROR 1044 (42000): Access denied for user 'root'@'%' to database 'normal'
Is the Query right or wrong? or How will I used (or) handiled the FUNCTION option?
If any one knows, please guid me

View Replies !
Mysql 4 Function From A Mysql 5 Function
I found this function on the mysql website :

CREATE FUNCTION substrCount(x TEXT, delim varchar(100)) RETURNS int
RETURN (length(x) - length(REPLACE(x, delim, ''))) / length(delim);

That works perfectly with mysql 5. But when I try to import this to mysql 4, I have an error :

suse-server:/partages # mysql mybase <function-add.sql> output.tab
ERROR 1064 (42000) at line 1: You have an error IN your SQL syntax; CHECK the manual that corresponds TO your MySQL server version FOR the RIGHT syntax TO USE near '(x TEXT, delim varchar(100)) returns int
return (length(x)-length(REPLACE(x, del' at line 1

View Replies !
NOW() Function MySql
We are developing a tool here that uses a php script to insert data into a MySQL 5.0.41 database running with the INNODB engine. While tracking a bug we noticed a strange effect.
Each insert query contains a call to the NOW() function to store the create data of the record into a field automatically. Therefore we can expect in my opinion that the timestamps of the records are increasing simultaniously with the autoincrement key of the table. This actually is not the case. On the contrary the timestamps are jumping up and down with large differences. For example we have the record with ID1 that got the timestamp 14 minutes 2 seconds where ID2 got 15 minutes 15 seconds and ID3 14 minutes 9 seconds. How could this be? Does it mean that the server does not execute the statements in the order he receives them? Is it possible that it took more than a minute to execute a simple insert statement?

View Replies !
MYSQL Function For 'or'?
In the context of a where statement, what is the correct way to say 'or' as in the following:

SELECT * FROM table WHERE field1 [or] field 2 LIKE "%$query%"

This is for a basic search feature where people are tending to misspell words, I'd like to add a search words column that will also be searched.

View Replies !
Is There Trigger Function In MySQL ?
It seems to me that there is no trigger function in MySQL but I am =
not sure.

Recently, I have a project which need the trigger function when MySQL =
database server receive a alert information and wake up some procedure. =
Is there any other method to do the same functionality of trigger as in =
ORACLE databse ?

View Replies !
MySQL Now() Function Problem
I am new to MySQL and my problem is with storing a datetime value in a
table. I created a table with a column designated as DATETIME. I
fill it with the NOW() function. No matter whether I default it or
try and set with code, all I get is a date! Even running "SELECT
Now()" only returns a date.

If I run the following query:

Date_Format(now(), GET_FORMAT(DATETIME,'USA'))

it returns a datetime value. However, if I use that SAME query to try
and fill the column during insert, I still get only a date value.

I've even tried some date calculations like Now() + 0 but still get
ONLY a date, no time info.

View Replies !
Any Hash Function In MySQL?
i'm not sure if u all know what hash algorithm is?

it's supposed to make retrieval of data much faster

i was wondering if there's such stuff in MySQL?

View Replies !
MySQL IF() Function Problem
I want to select 2 dates from a database (fields called start_date and end_date). However, I want to in some way make the returned value of end_date equal to that of start_date if end_date is null.
I've tried using the if() function as follows:

$result = mysql_query("select start_date, if(end_date is null, start_date) from events");

Where events is my table name. This doesn't work. I've tried it with quotes around start_date in the if but that just returns the word start_date.


View Replies !
Push/pop Function For MySQL
if MySQL has a push/pop function? I'm creating a table for news items, with three rows - one for the date, one for the title, and one for the URL. What I want to do is limit the number of news items held in the table to 10. For example, if there are 10 entries in the table already (date/title/url sets) and I add another item, I want to put it at the top of the table and pop the bottom value off the table.

I know I can do this by exporting the table to an array in PHP, then messing with it there and writing it back to the table, but this would take a lot of MySQL queries I think.

Is there an easy solution to this problem I'm not seeing?

View Replies !
Something Like A RANGE() Function In MySQL?
Is there something like a RANGE() function in MySQL?

I am trying to optimize some of the data retrieval methods I am using in one of my PHP projects that make use of MySQL. The query I am using now is as follows:

Code:

SELECT id, (id - 59) AS day, 3 AS month, title, isRedLetter, important FROM `fixedfeasts` WHERE id BETWEEN 60 AND 90 LIMIT 31


The problem is that the value of the day column depends on the value of the id column which is something I would really like to avoid. Is there a MySQL function which would produce a range of values something like this:

SELECT id, RANGE(1, 31) AS day, 3 AS month, title, isRedLetter, important FROM `fixedfeasts` WHERE id BETWEEN 60 AND 90 LIMIT 31

Bottom line... I need something that will produce the following results:
id, day, month...

61, 1, 3...
62, 2, 3...
...
90, 31,3...

View Replies !
Split Mysql Function
am doing the search process,

user enter the two key word like this php,html

i want to split this keyword and execute this into mysql,i want to

split this using the mysql function, i know we can to this using the

php split function , but i dont want to this using PHP functions,

so looking solution in mysql function,

also it dont stop the good performance ,

View Replies !
Variable Function In MySQL
Is there a way to use a 'variable function' in MySQL, e.g.Code:

SELECT @hash:= value FROM prefs WHERE key = 'hash_method';
-- @hash = SHA1
SELECT @hash('test string');

So the variable @hash stores the current hash method in the `prefs` table.
This method does not work, is there a way to do this?

View Replies !
Recursive Function In Mysql ?
My table
--------

id -- value -- ref_id
----------------------
1--rqwer-0
2--23ew-1
3--23ewe-2
4--123ff-1
5--de123-4

Now i want to take the values like id and refer has to be same and one more condition ,
i need the output as

1,2,4,5

How can i get ?

View Replies !
Mysql Stored Function ...
I'm new to creating stored procedure - can someone tell me where i've gone wrong here - the below code refuses to execute. Essentially, all i want do it something like;

INSERT INTO sometable(a,b,c) VALUE(12,'12',itypes('information'));

if the category 'information' doesn't exist in the event_types table, it's create and the id return - else just returns the id

CREATE FUNCTION .`itypes` ( _tname VARCHAR(45))
RETURNS INT
BEGIN
DECLARE tmp INT;
SELECT id INTO tmp FROM event_types WHERE tname LIKE _tname;
IF (id IS NULL) THEN INSERT INTO event_types ( tname ) VALUES ( _tname );
END IF;
SELECT id INTO tmp FROM event_types WHERE tname LIKE _tname;
RETURN tmp
END

View Replies !
ENCRYPT Function In Mysql
My password column is encrypted using ENCRYPT() function. When I execute the following query in phpmyadmin, it is showing 0 records. Because everytime, encrypt function is executed, it is returning new value. But my squirrelmail application is decrypting the password correctly.

$query="SELECT * FROM users WHERE email = 'xxx@xxx.com' and password=ENCRYPT('smart')";

how to check whether the user entered password is correct as in mysql?

View Replies !
Init_cap() Function In MYSQL
Is there any string function available to get the First Character alone with upper case in MYSQL5.0

For Ex:
remma.

Output:
Remma

View Replies !
The Function 'IN' Causes Error In MySQL 4.1.9
I am currently using MySQL 4.1.9 and I'm planning to upgrade to MySQL 5.0 soon. But for the mean time, I am experiencing problems with the function 'IN'. Here's the error message I received..

#1270 - Illegal mix of collations (latin1_swedish_ci,IMPLICIT), (utf8_general_ci,COERCIBLE), (utf8_general_ci,COERCIBLE) for operation ' IN '

View Replies !
UNION Function How To In MySQL 3
How to write this line in mysql3 where there is no UNION function?

(SELECT * FROM table1) UNION (SELECT * FROM table1) ORDER BY date LIMIT 0,5;

View Replies !
Mysql Date Function
I just want to know if this command below is acceptable in MySQL form? Because, I have made a web form processing in which the date is basing as EST time (east standard time in US) and I'm in ASIA. I just found a mysql function date thru googling..

$sql = "INSERT INTO table SET
date = SUBDATE(NOW(), INTERVAL 1 DAY)";

View Replies !
Mysql IF Function Question
I am trying to incorporate an IF statement into a query so that it will show a P after a phone number if this phone is a personal cell phone. This is being used in a view that I use in multiple locations to create phone listings of all employees in the directory.
My query is:

CREATE VIEW phonelisting as select
users.UserID,
concat_ws(' ', users.fname, users.minitial, users.lname) userName,
users.positionTitle AS positionTitle,
group_concat(distinct concat('(', substr(CAST(did.DIDID as CHAR), 1, 3), ') ', substr(CAST(did.DIDID as CHAR), 4, 3), '-', substr(CAST(did.DIDID as CHAR),7 , 4)) order by CAST(did.DIDID as CHAR) ASC separator '<br />') dids,
group_concat(DISTINCT CAST(phone.ExtensionID as CHAR) ORDER BY CAST(phone.ExtensionID as CHAR) ASC SEPARATOR '<br />') extensions,
users.homePhone,
users.pager,
group_concat(distinct concat('(', substr(cell.number, 1, 3), ') ', substr(cell.number, 4, 3), '-', substr(cell.number,7 , 4)) order by cell.number ASC separator '<br />') AS cellphones
FROM
users
LEFT JOIN
cellrelationship
ON
cellrelationship.userID = users.UserID
LEFT JOIN
cell
ON
cell.CellID = cellrelationship.cellID AND cell.hideListing <> &#391;'
LEFT OUTER JOIN
phonerelationship
ON
users.UserID = phonerelationship.UserID
LEFT OUTER JOIN
phone
ON
phone.PhoneID = phonerelationship.PhoneID
LEFT OUTER JOIN
DID
ON
did.ExtensionID = phone.ExtensionID
WHERE
users.userStatus <> 'term'
AND
users.hideListing <> &#391;'
AND
(users.termdate = '' OR users.termdate >= UNIX_TIMESTAMP(CURRENT_DATE))
AND
users.hireDate <= UNIX_TIMESTAMP(CURRENT_DATE)
GROUP BY
users.UserID
ORDER BY
userName
I would like to have the P show up at the end of each phone listed(Only if it is a personal phone) on the line with:


group_concat(distinct concat('(', substr(cell.number, 1, 3), ') ', substr(cell.number, 4, 3), '-', substr(cell.number,7 , 4)) order by cell.number ASC separator '<br />') AS cellphones
The way I determine if it is a personal cell or company cell is by the value of cell.Type being Company or personal.

Any suggestions?

*I am running mysql 5.0.27

View Replies !
Is There A Addslashes()-type Function In Mysql Or Sql
I was wondering if there was a way to automatically add escapes to a string in either SQL standard or MySQL, such as addslashes() in PHP. I'm looking for something like the quote() function but without the need for quoted strings?

View Replies !
PHP/MySQL, No Longer Connecting To Db When In Function
I'm trying to clean up the code so that design changes will be easier. So, I've put the

$connection = mysql_connect($hostName,$username,$password) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db($databaseName, $connection);

etcetera... with output commands in global functions().

But for some reason (why?), it no longer "reads" the original include with all the database variables. Is there a way to help these new functions "read" the previously set variables?

View Replies !
Escaping Charater Function In Mysql
Is there any escaping character function available in mysql. I am creating report using stored procedure by concat various data's. Within the data's some special character found like (" ' ) i need to escape those character from mysql function.

View Replies !
Is There An 'Is Negative' MySQL Query Function?
I have a query, as shown below. Its a grouped query and I have a column called quantity in a products table. If the value in this table drops below zero I want the query to take zero as the quantity. Is this possible?.....

View Replies !
An IMPLODE() Type Function For MySQL??
I'm looking to pull data (just one column) from mysql which is over multiple rows.

e.g.

apple
banana
orange
pear

Now, I actually want the data in this format in just one row:

"apple,banana,orange,pear"

Does mysql offer some sort of "SELECT IMPLODE(',', my_column) AS foo" type of thing? I know I can do it with PHP but this a part of a much larger query so I'm trying to keep this all in a single query.

View Replies !
Why Does GROUP_CONCAT() Function Fail In MySQL 4.1.12 In This Query?
Here are my results using MySQL 4.1.12 and I honestly don't think this is right, but can't figure out what to do:

View Replies !
SQLColumns Function And MySQL ODBC Driver
The MySQL ODBC driver returns an error when calling SQLColumns function with an empty Table parameter:

[MySQL][ODBC 3.51 Driver][mysqld-4.0.18-nt]Can't use wildcards in table name

Is there a newer version which supports wildcards in table name? Actually I don't really need wildcards, but I need to get the list of all columns in all tables.

View Replies !
What Is The NOW() Function In A MySQL DateTime Field Query?
I have a monitoring script which I am trying to better understand. One of the queries is built as follows: .....

View Replies !
How Can I Execute A PreparedStatement Inside Mysql Function
How can i execute a preparedStatement inside mysql function?

View Replies !
Stored Function Stops MySQL Service
I'm using MySQL 5, Windows XP Home SP2 (ack, but only for the near future)... I have what appears to be a simple and straightforward need- execute a function for a column in each row of a result set: Code:

View Replies !
Mysql Appears To Have Changed The 'password' Function Hashing
I've been using Mysql for about 6 months but in fairly basic fashion. For a cms I have built, I have a users table, with userName and password fields. An admin can create new users, and the password is hashed using the PASSWORD() function.
SQL: "INSERT INTO users VALUES ('', '$userName', PASSWORD('$userPwd'))

Straight out of the book basically. Now the problem is that all this has been functioning fine on a couple of sites on external servers, plus a couple of local machines.

Until today, on my main dev machine - yesterday a user could log in, today they couldn't. As far as I can tell, nothing has changed. But when I look at the hashes in the database table, they are 41 chrs, and when I add a new user, the hash is 16 characters.

I know that at some stage the hash length was increased between mysql versions, but I have not updated the install (I run XAMPP for Windows 1.4.14, which appears to install php 5.0.4 and mysql 4.1.12)

Is there any other reason that the hash length could change to 16? I'd like to know why this happened so that I'm prepared if it happens on the server (where it is not so easy to hack in and add new users that can log in again)

View Replies !
Wot Is The Function To Count The Records In Selelct Statmtn In MySQL
wot is the function to count the records in Selelct statement in MySQL?

Just like
PHP

mysql_num_rows($result);

in php.

View Replies !
Mysql_connect() [function.mysql-connect]: Access Denied For User
i got this error after uploading all the files in www folder. i'm using wamp.

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home/.../public_html/....com/includes/connection.php on line 5

Database connection failed: Access denied for user 'root'@'localhost' (using password: YES)



View Replies !
Connecting To Mysql Server :: Call To Undefined Function Mysql_connect()
Whenever i try to connect to mysql server, i get this:

Fatal error: Call to undefined function mysql_connect() in ........ on Line ....

What's wrong?

i've mysql and apache installed on an external drive and both of them are working individually. Their host is localhost and the port for apache is 81 and for mysql is 3306.

View Replies !
Linux Mysql Nfs : Bind On Unix Socket: Function Not Implemented
I have installed Mysql on red hat ES release 3 and i was working great.

For my applications, I decided to to put the data directory on another machine. The other machine is a big disk of storage (Adaptec snap server 1 terabyte)
It working great for all applications except Mysql

In fact, i put /var/lib/mysql on another machine and I made a nfs mount

When i try to start mysql i have this :

/etc/rc.d/init.d/mysqld start
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]

in the error message i have this

051028 11:12:33 mysqld started
051028 11:12:33 Can't start server : Bind on unix socket: Function not implemented
051028 11:12:33 Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?
051028 11:12:33 Aborting

051028 11:12:33 /usr/libexec/mysqld: Shutdown Complete

051028 11:12:33 mysqld ended

I have verified the permission and everything seems to be ok....

View Replies !
Warning: Mysql() [function.mysql]: Access Denied For User 'apache'@'localhost' (using
my script is not connecting to my database, i get this error

Warning: mysql() [function.mysql]: Access denied for user 'apache'@'localhost' (using password: NO)

View Replies !
User-defined Function: ERROR 2013 (HY000): Lost Connection To MySQL Server During Query
With mysql-4.1.1-alpha, using any User Defined Function ( UDF) at the
query execution stage, on Linux 2.6, gave me the following error:

"ERROR 2013 (HY000): Lost connection to MySQL server during query"

However, upgrading to mysql-4.1.2-alpha seemed to solve the problem.

Both versions were configured exactly as follows

../configure --with-openssl --enable-thread-safe-client --with-mysqld-ldflags
=-rdynamic

The only way I could solve this was by upgrading to 4.1.2-alpha-log. Then,
recompiling the functions, drop the old UDF functions, then, recreate.
So far so good.

Anyway, if you run into this problem, or just want more detail on the sample
User Defined Functions that come with MySQL ( /sql/udf_example.cc), I've put
my notes in the following link ( TIP 27 )

View Replies !
Warning: Mysql_connect() [function.mysql-connect]: Access Denied For User 'debscrof'@'localhost' (using Password: NO)
Have MySQL on a VPS running CPanel
MySQL v4.1.22-standard

Can access MySql fine through CPanel, phpMyAdmin etc all work fine, creating databases, deleting databases, adding users etc

However, when I try to use MySql from a website, it fails

I created a user "test1" (which then got the username "debscrof_test1" from CPanel), a password for the user "test2", and then added the user to a new database "testdb" with all priviliges

Then a simple script to connect to the database (as I am trying to locate the source of the errors), as per below:

<?php
$dbhost = "localhost";
$dbuser = "debscrof_test1";
$dbpass = "test2";
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'debscrof_testdb';
mysql_select_db($dbname);
?>

Have tried with " and ' around the values, with 127.0.0.1 as the host... still with the same error message:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'debscrof'@'localhost' (using password: NO) in /home/debscrof/public_html/testdb.php on line 6

Error connecting to mysql

...any suggestions why I cannot connect? (and why it says password: NO)!

View Replies !
Max Function
I have a table with name, priority and parent as three columns...I want to get the max(priority) grouped by the parent... I am trying to get name, priority, parent, max(parent) as the four columns in the result...Could some one help me with this

select name, priority, parent from table1
select max(priority) from table1 group by parent

are the two select statements that I wish to combine...is it possible..?

View Replies !
SQL IN() Function
so i have a query such as
SELECT first_name FROM users WHERE user_ID IN (5,4,8,19,8,4) and i want the first_name to be retrieved for EACH of the cases (eg. name is repeated twice for 4 and 8)

View Replies !
Last Function
How do you get the last row in a grouped query. I have a table with running balances. At the end of the day, I want to find out the last balance.

select *
from accounts
group by date(dateCol)

This always gives me the first row of the grouped column dateCol.

View Replies !
Avg Function
Why doesn't this work:

SELECT avg(value) as avg_value from playerstats where avg_value = '100' and stattype = 'r' group by avg_value

I'm trying to select the avg_value of 'r' where the avg_value = '100'.

View Replies !
Looking For A Particular Function
I have a Column which consists of only DATE's and an ID code. I want to enumerate all the DATE's of a certain ID to get a grand total of a ID. Does such a function exist?

View Replies !
Using The AVG Function
I am trying to use this query:

SELECT average(price) FROM `data` WHERE id IN ( '3', '3', '6' )

to average the price of items users select. The problem is that when a user selects a value more than once it only includes it in the average once. How can I make it average all the values?

View Replies !
Now() Function
I am using now function to get current date when info is added to my table. I am using a hosting provider that is 6 hrs ahead in time zone so i always have to subtract 6hrs to get the correct time. Is there anyway I can format the time to be inserted to my time zone?

View Replies !
SOUNDEX Function
I'm using SOUNDEX mysql function to find similar sounding names from
a table with 2 million distinct names.

Unfortunately there is a single soundex code for every 200,000 names!
Meaning there are only 200,000 distinct codes for 2 million entries.

Is there any other function / library / technique to work around this
immense 1:10 redundancy ?

for example, soundex for 'avis', 'apex' and 'apps' is A120, but I'd
like to differentiate between them in my search - meaning implement a
"stricter" sound comparison than the soundex function offers.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved