 |
|
 |
Create a C/C++ console application which connects to MySQL database and insert a new column of type varchar into a given table.Ask the user for table and new column name.
Plz someone answer dis....
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
I am accessing a database using the following command:
SELECT SensorID, State, NumKey, MAX(DateTimeEvent) FROM Sensors GROUP BY SensorID
The SensorID and DateTimeEvent match but State and NumKey are not from the same row as SensorID and DateTimeEvent. The State and NumKey are coming from the first entry found in the table.
So the command returns the following: SensorID - ABC123 State - 0 NumKey - 16 DateTimeEvent - 2009-11-17 13:00:00
But the State and NumKey, associated with the SensorID ABC123 and DateTimeEvent 2009-11-17 13:00:00 are 4 and 46 so looking at the row in the table it is: SensorID - ABC123 State - 4 NumKey - 46 DateTimeEvent - 2009-11-17 13:00:00
Any idea what is going on? What I am trying to do is sort on SensorID and pick the row with the highest DateTimeEvent.
Thanks, Jim
I told my daughter age 7 to hold her breath, it was OK as I would be breathing. She looked at me oddly but complied. When she could no longer hold her breath she blew it out gasping. I asked why she let out her breath. She yelled angrily, "DADDY, YOU CAN'T BREATHE FOR ME. I HAD TO BREATHE OR I WOULD DIE!" I smiled and quietly told her, "Just as breathing is essential to life and can be done only by you for you, so is thinking. Do not ever believe that you can let someone else do your thinking."
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello. I'm having a little trouble getting this query to work:
$userId = mysql_real_escape_string( $_SESSION['user_id'] ); $userPassProvided = mysql_real_escape_string( $_POST['oldPassword'] ); $query = "SELECT user_id, AES_DECRYPT( user_pass, '".$db_aes_key."' ) AS user_pass "; $query .= "FROM users_tbl WHERE MATCH( user_id, user_pass ) "; $query .= "AGAINST( '".$userId."', '".$userPassProvided."' IN BOOLEAN MODE ) LIMIT 1"; $result = mysql_query( $query, $mysql_db );
What I would like to do is query users_tbl for the record wherein user_id and user_pass are the same as $userId and $userPassProvided, respectively. Can someone please tell me what is wrong with my query?
Thanks. 
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
not completely sure, but I think your SQL statement will search for $userPassProvided in field user_pass, and only when some row matches, will it return what you specified, including a decrypted password. If so, you should encrypt $userPassProvided.
And I don't like two-way encryption for passwords; most often all you need is validating the user, which can be done with a one-way encryption (i.e. get password as entered, encrypt it, search it in the DB).
BTW: I'm baffled by the MATCH...AGAINST in there too; you do want a full match, don't you?
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Thanks, Luc. If I understand correctly, I should be doing something like this (untested of course):
$userId = mysql_real_escape_string( $_SESSION['user_id'] ); $userPassProvided = mysql_real_escape_string( $_POST['oldPassword'] ); $query = "SELECT user_id, AES_DECRYPT(user_pass, '".$db_aes_key."' ) AS user_pass "; $query .= "FROM users_tbl WHERE MATCH( user_id, user_pass ) "; $query .= "AGAINST( '".$userId."', AES_ENCRYPT( '".$userPassProvided."', '".$db_aes_key."' ) IN BOOLEAN MODE ) LIMIT 1"; $result = mysql_query( $query, $mysql_db );
Yes, I do want an exact match. This is going to be used in a User Control Panel on my website when the user wants to change their password.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
for an exact match, you don't need MATCH...AGAINST, a simple "... WHERE field1 = 'value1' AND field2 = 'value2' ..." would do.
And you don't need to SELECT the password, the user_id should be sufficient. After all, you either get zero or one rows that match.
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi All, In MYSQL 1)we migrated one project from Oracle to MYSQL. There is one Procedure that is called by many other procedures. We will call the procedure Level2 (Called Procedure) The Level1 (Calling ) Procedure is calling the Level2 Procedure. If something Fails in Procedure2 - Level2 (.. Called Procedure ); Any other statements in Level1 Procedure before calling proc level2 - should be rolled back since autocommit=0; In Oracle this works fine. Can some one tell How to implement the same in MySQL - Innodb. Or do we have to use falcon for the same. (In MySql as soon as we call the Level2 Procedure in Level1 - In Level2 procedure there is begin and due to this begin the previous trnasactions are commited )
Details : Table T
DROP TABLE IF EXISTS `bestr`.`t`; CREATE TABLE `bestr`.`t` ( `c` binary(3) DEFAULT NULL, `Col1` varchar(45) NOT NULL DEFAULT '', `Col2` varchar(45) DEFAULT NULL, `LCT` datetime DEFAULT NULL, `DeleteFlag` varchar(1) DEFAULT NULL, PRIMARY KEY (`Col1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Insert into t Values ('1', '1', '1', CURRENT_TIMESTAMP, 'N');
Insert into t Values ('1', '2', '1', CURRENT_TIMESTAMP, 'N');
Insert into t Values ('1', '3', '1', CURRENT_TIMESTAMP, 'N');
-------------------- Proc 1 ---------
DELIMITER $$ DROP PROCEDURE IF EXISTS `bestr`.`lEVEL1` $$ CREATE DEFINER=`BESTR`@`%` PROCEDURE `lEVEL1`( INO varchar(26), Out R2 Int, Out RC Int ) Begin Declare R1 Int; Set AutoCommit=0; Set R1=0; Set R2=0; START TRANSACTION ; Update T Set COL2 = Col2 + 1 Where COL1 = INO; -- Block1 Call Level2 ( INO, R1, RC); Set R2=R1; -- Block 1 end (Note if Block 1 is commented the transaction is implemented properly. -- Set R2= ROW_COUNT(); if R1 > 0 then Commit; else RollBack; end if; end $$ DELIMITER ; ======================================================== DELIMITER $$ DROP PROCEDURE IF EXISTS `bestr`.`lEVEL2` $$ CREATE DEFINER=`BESTR`@`%` PROCEDURE `lEVEL2`( INO2 varchar(26), Out R1 Int, Out RC int ) Begin Set AutoCommit=0; Set R1=0; START TRANSACTION; Select Count(1) into RC from T Where COL1 = INO2; Update T Set LCT = CURRENT_TIMESTAMP Where COL1 = INO2; Update T Set C = 'FailTest' Where COL1 = INO2; Select ROW_COUNT() into R1; if R1 > 0 then Commit ; else Rollback ; end if; end $$ DELIMITER ; ========================================================== --------------------------------------------- Call Level1 ('3', @R1, @R2);
Select @R1, @R2; 2) Is reliable, tested falcon Download link is available? Your inputs will be very useful.
Regards Manoj
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Can we get an sql server on internet. Means i want to create a database my system doesnt support sql. So are there any server thats i can create and use it online through internet.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
table A Field "stuage" 15 15 16 17 15 16 17 18 15 16 17 18 if do this:select * from A it show:15 15 16 17 15 16 17 18 15 16 17 18 but how can make it show:15 16 17 18,not repeat! thanks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi..
Use distinct keyword.
select distinct (stuage) from A
this'll avoid the duplicate values.
Regards, Gokula R.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi All,
I need to return a value with a string appended on the front of it, but I don't want to modify the table. is this possible with mysql?
Eg:
SELECT type FROM table
Currently returns: "basket" and "cart"
But I'd like it to return: "Shopping basket" and "Shopping Cart" (appends "Shopping " before the returned each of the returned values). I thought I could use the CONCAT function but that doesn't seem to work.
Any ideas?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi Marc,
this should do it:
SELECT CONCAT('Shopping ',type) AS type FROM table
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
In MS Sql Server 2005 I want to create a Stored procedure that will generate a report.
However I don't want to have to recreate or update stored procedures when the number of columns increase or decrease.
Here is what I am needing. I need to create a dynamic table that will increase the number of columns in that table based on the results of the select statement.
Sample: Select PartName from Parts --PartName will return anywhere between 5 to 200 results or more.
DECLARE @ToolsTrackingBoard as TABLE ( JobNumber int, [Job Name] [nvarchar](100) ...All the additional column names are the names from the (Select partname from Parts) query. )
select * from @ToolsTrackingBoard
How can I do this? I have been hunting for days.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
HI, i need the query to dump a database to or a database table to an sql dump which i can restore with the LOAD DATA INFILE.. command. Thank you in advance.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi,
I have a table like this one:
Num DateStart DateEnd 1 10-10-2000 12-01-2001 1 09-01-2000 12-01-2000 1 01-01-2005 12-30-2009 2 01-01-2004 01-01-2005 2 01-01-2006 01-01-2007
I have to group by Num, but only if the interval (Date) is included in another. The new DateStart needs to be the lowest DateStart and DateEnd the biggest DateEnd.
Here's the result I want: (Only the first 2 rows are grouped)
Num DateStart DateEnd 1 09-01-2000 12-01-2001 1 01-01-2005 12-30-2009 2 01-01-2004 01-01-2005 2 01-01-2006 01-01-2007
Thanks,
Martin
========================== Martin Bonneville Analyst-programmer
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi, I am working on a project which is to get an image,precisely a fingerprint image from a fingerprint reader and store into or retrieve from the database(MySQL).I understand that i can use the data type blob in MySQL,I dont know how to go about it in C#.I will really appreciate any help rendered.Thanks.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Hi,
Which method is the best way to transfer realtime data from one sqlserver to another sqlserver.
Plz let me know..
Thanx...
krishna veer singh
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
:(
Luc Pattyn
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
Local announcement (Antwerp region): Lange Wapper? Neen!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi there,
I have tried running a query using the DISTINCT keyword, but the result is not what i am looking for.
The table is something like the following:
name age AA 12 BB 13 cc 18 AA 14 BB 19 If i query: Select Distinct name, age from table; i get all the rows.
I am intested in a result set that will be:
name age AA 12 BB 13 cc 18
Can anyone help?
Thank!
Edit: 1. I know that distinct works on the combination of the colunms, giving a distinct set of rows, but that is not what i need. I need it to be distincted by the name. 2. Running Select Distinct(name), age from table; doesn't give the correct result either.
modified on Sunday, October 11, 2009 10:37 AM
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Just to let you know, i solved the problem.
select distinct(name), age from table group by name; did the job.
Thanks.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I have a records in datatable. I need to pass them all at a time to data base and i need to process the list in a loop.
In sqlserver I can send it as XML string.Mysql does not support xml I think.
please provide the solution and guide me.
Thanks in advance, Srinivas Mateti
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |