mysql

How to get first day of every corresponding month in mysql?

Hi, I want to get first day of every corresponding month of current year. For example, user selects '2010-06-15', query demands to run from '2010-06-01' instead of '2010-06-15'. Please help me how to calculate first day from selected date. Currently, I am trying to get desirable using following mysql select query:- Select DAYOFMONTH(...

Unique constrain with condition MYSQL

Hi! I have User table in my DB. A user has the fields name, company_id and status: boolean, 1- live, 0- deleted. When a user is deleted, his status is set to 0. The combination of a live user name in a company should be unique. After a user is deleted, I don't mind that a user should be created with the same name for the company. ...

How to concatenate the output of a SQL query into one string

I am newbie in writing SQL queries and this is for a mySQL database. I have a Table called PatientVisit (PV), which has a one to one with BillMaster (BM). Each visit has one bill, which then has a one to many with BillDetail (BD). When i list out the Visit details from PatientVisit (PV), i need to print a string with the set of 'Servic...

php and mysql (for numerical operations)

i have two tables in mysql . i want to add or subtract values from one table from another. i expect clear answer. please help me ...

adding 2 1/2 hours to a time object in python

Hello all, I need to be able to convert time on an time object I recieve from a sql database into python. Here is the current python code I am using without any conversions. I need to add 2 and 1/2 hours to the time. def getLastReport(self, sql): self.connectDB() cursor.execute(sql) lastReport = cursor.fetchall() dat...

Encrypted columns with Entity Framework

Anyone figured out a good way to pull encrypted values from db through entity framework 4? I got a MySql db with some columns encrypted with des_encrypt and need to be able to get those values as easy as possible, and also of course, update and insert them. I think it's quite strange there doesn't seem to be in built support for this i...

unexpected result from SQL - CASE statement returns value other than stated.

Hi, Can anyone help me explain why the changed line below returns a 0 instead of the requested 11 or 12? I'm using MySQL, and this query otherwise runs, correctly... I'm attempting to catch the difference between a 0 and a null in the said field. SELECT SUM(CASE WHEN pr.heatEventID=1 THEN pr.points+1 ELSE '-' END) AS `100m` , SUM(...

The SqlParameterCollection only accepts non-null SqlParameter type objects, not MySqlParameter objects.

Hi, I have created a method that will insert any exceptions thrown into a table on "ExceptionLog" on MySql server. ExceptionLog Table format idExceptionLog int (AI) User (varchar 45) ErrorMessage (varchart 4000) The problem is i keep getting the following error. Does anyone know why? The SqlParameterCollection only accepts non-...

How to configure the structure of a mysql database

Is it possible to restore the previous state of a mysql database through phpmyadmin? I have one column in 4 of the tables that have the auto increment. And my problem is how to begin again in the count of number 1 when I try to add a data. I tried deleting all the records then add a record but it doesn't start with 1. How do I do this w...

How to pass multiple dynamic url parameters to my pagination pages when a user searches the site using PHP & MySQL

I was wondering how can I pass multiple dynamic url parameters to my pagination pages when a user searches the site using PHP & MySQL in order to display their results? Here is the HTML form. <form action="search.php" method="post"> <input type="text" name="search" /> <input type="submit" name="submit" value="Search" /> </form>...

mysql: reading cursor

Hi all, I defined the next stored procedure: CREATE DEFINER=mydb@% PROCEDURE CorrectMsisdns() BEGIN DECLARE sizetmp INT DEFAULT 9; DECLARE idtmp VARCHAR(32) DEFAULT ""; DECLARE msisdnorig VARCHAR(16) DEFAULT ""; DECLARE new_msisdn VARCHAR(16) DEFAULT ""; DECLARE msisdns CURSOR FOR SELECT id, msisdn FROM profile WHERE msisdn LIK...

Insert last id from one table into another

I have two tables, articles and logs. When new record is inserted into the articles table the ID of that article should be inserted into the logs table after that... How this can be done using mysql/php? Can anyone please provide an example of code? ...

Facebook application - basic database design

My User table (mysql db on a other server) has a FaceBookId Column. How do i filter it by friends? I mean Select * from User where FacebookId in SomeTypeOfGetFriends(of me ... the logged in user) what's the best way? should I first get the friends in an array, then do a FacebookId IN (array) ? OR: For every user that logs on, I co...

change data in textbox using text changed attribute in vb.net

I've tried loading a mysql data into vb.net data grid view and it is dynamic. Dynamic meaning, it changes its contents whenever I type different text in the textbox. How do I do it in a textbox. When I load data into it. I just need to change its contents whenever I try to type a different word on the textbox which I use to search: Here...

How can you pass multiple search parameters a user enters through the query string when generating pagination links using PHP & MySQL?

How can you pass multiple search parameters a user enters through the query string when generating pagination links using PHP & MySQL? Here is the HTML form. <form action="search.php" method="post"> <input type="text" name="search" /> <input type="submit" name="submit" value="Search" /> </form> ...

Multiple table Outer Join problem

I may have have the wrong end of the stick here, but I thought that an outer join was supposed to give me all the records that were in either the (say) left table, along with the matching results from the right table, and nulls where there was no match. I have 3 tables I need to query. Person and Detail have a direct 1:1 relationship. ...

How to select rows based on unique column

Hi, I have table with values as ColumnA ColumnB ASD A CSD B DSD C ESD D FSD D GSD D Column A is primary key, I need result as ColumnA ColumnB ASD A CSD B DSD C ESD D I want all unique values from column B & their a...

SQLAlchemy truncating Column=(Integer)

Hi guys, weird issue here: I have a reflected SQL alchemy class that looks like this: class Install(Base): __tablename__ = 'install' id = Column(Integer, primary_key=True) ip_address = Column(Integer) I convert the string representation ("1.2.3.4") to int using: struct.unpack('!L', socket.inet_aton(ip_address))[0] This...

recursive function category database

hello i hoping to create a recursive function which i don't have an idea yet this is my code to fetch category from database <?php $sql = mysql_query("SELECT * FROM categories WHERE category_parent = '1' ORDER BY lft ASC"); while($row = mysql_fetch_array($sql)) { echo "<li><a href='/{$row['category_safe_name']}/'>{$row['catego...

Need to intergate IDX MLS into a website

Are there any free IDX or MLS integration scripts available? I want to do a website in which I can integrate the MLS data into the site database but I have no idea how to go about it without seeing some type of working script. Any help or direction would be greatly appreciated. ...