mysql

Many-to-Many self-referencing select sql query

I have a simple table (MySQL) set up for relationships between two users. [User1Id] [User2Id] 10 15 14 10 10 13 But, I can't figure out how to do a SELECT in such a way that I can grab the opposite UserId of the user being requested. So, if I wanted to get all relations for the user with an ID of 10, it wo...

Binary vs Integer - as primary key?

I was wondering if there are any obvious pros and cons one should be aware about, while choosing to use a Binary type as a primary key, while being RANDOMIZED. Which means, new inserts will have random 4 bytes as their PK - versus having a sequence of type Integer? I'm using MySQL/MyISAM. Thanks, Doori Bar ...

How to create a communication setup between a Mysql and a MS SQL Server instance?

Hi, I have two separate appliations running on the separate infrastructure. app-a is using MYSQL as it's database server and, app-b is using MS SQL Server as database server. I have got requirement to constantly read some tables in the MS SQL server and populate some table in MYSQL server. I got clue about setup a communication environ...

Using INNER JOIN with MySQL on selecting multiple tables?

Hi all, I have a site where a specific set of data is collected. This is a travel agency website. It is neccesary to determine whether or not an accommodation is still bookable. When I don't select any searchfilters (like destination, classification, facilities etc) I get a working query. The looks like: SELECT `accommodation` . * FROM...

PHP Fatal error: Call to a member function execute() on a non-object

Hello, I get the error PHP Fatal error: Call to a member function execute() on a non-object refering to the ....->execute() line whenever I call something like $select_str = 'select id, stamp, lat, lng, spd from gps'; $select = $db->prepare($select_str); $select->execute(); or $insert = $db->prepare('insert into gps (id, lat, lng, ...

Help writing a fast complex query

Hi, I'm trying to write a query to get a courses information and the number of bookings and attendees. Each course can have many bookings and each booking can have many attendees. We already have a working report, but it uses multiple queries to get the required information. One to get the courses, one to get the bookings, and one to g...

SQLAlchemy JSON as blob/text

I'm storing JSON down as blob/text in a column using MySQL. Is there a simple way to convert this into a dict using python/SQLAlchemy? ...

Searching MySQL with AES Encryption

Hello, I am just curious if someone can get me pointed in the right direction with searching MySQL with AES encryption. There are a couple of things that need to be considered. If I take the keyword and encrypt it before searching, i'm comparing encryption to encryption and even if one letter is cap and another letter isn't cap insid...

KnowledgeBase article creation mechanism for php, jquery, mysql

I am looking to create a general knowledgeBase for my customer service department which takes information (my thought is from a mysql database) and populates a page with that information based on the content pulled. Take this site for example: ToastMaster I would like to store a primary title, main content, images, etc on my site witho...

Dreamweaver, PHP, MySQL

I have downloaded a backup copy of my cpanel webserver. I install WAMP on my local laptop.The database and php username and password have been set. Then I loaded the database into the local MySQL database. I verified the phpinfo.php is working. I setup dreamweaver manage site with the extracted website on my laptop. Now the back end adm...

How should I store a AES Encryption Key?

I run a DV 3.5 server on MediaTemple with Linux CentOS 5, php and mysql DB and am trying to encrypt phone records with AES. I came across what seems to be good script as PHPAES but I am not sure of the following: Where do I actually store the AES Encryption key used to encrypt and decrypt the phone number? How do I call on the AES ...

Creating an "at" job from command line for a MYSQL query

From the command line, I want to create an at job to run a mysql query. As you can imagine searching on google or here stackoverflow for "at" is difficult. This works fine and the query runs like it ought to: mysql -e 'MY QUERY;' but if I do this: at 17:30 mysql -e 'MY QUERY;' At 5:30 I get a mail that tells me "UPDATE: command n...

Basic MySQL Table Join?

I have these 2 tables: ASSOCIATION_TABLE: [id, key, name, manager, office, bank, customer] and OFFICE_TABLE: [id, name, address, phone] I am currently running this query to get a data set that I need: SELECT `name`, `key`, `office`, `manager`, `id` FROM `database`.`ASSOCIATION_TABLE` WHERE `association`.`customer`=4; How can I m...

Database suggestion for processing/reporting on large amount of log file type data

We have an app that creates text log files of requests to it. Pretty typical stuff in the log file and it is space delimited (date, time, url, http code, ip, user agent, etc). Currently, we are generating around 500k entries in the text log files per day. We're currently doing a lot of analysis via sed/awk/grep of the text files. Ho...

how does the groupby and count work in sql

1> select browser,count(*) from logtest group by browser; +-----------+----------+ | browser | count(*) | +-----------+----------+ | Firefox 3 | 14 | | Unknown | 11 | +-----------+----------+ 2 rows in set 2> select browser,count(browser) from logtest group by browser; +-----------+----------------+ | browser | cou...

MySQL: List instructors (names) who taught a section of CS160 and a section of CS340 in 99F term.

The schema is as follows: Student(Snum, Sname) Course(Cnum, Cname) Professor(Pnum,Pname, Dept, Office) Class(Cnum, Term, Section, Instructor) How can I join the two selects below to get Instructors who taught both CS160 and CS340? SELECT DISTINCT Instructor FROM class WHERE Term = "99F" AND Cnum = "CS160" SELECT DISTINCT Instructor F...

how do i copy one row to insert into the same table?

insert into table select * from table where primarykey=1 I just wanna copy one row to insert into the same table, but i don't want list all the columns after the "select",cause this table has too many columns. But when i do this, i get the error: "Duplicate entry 'xxx' for key 1" I can handle this by creating another table with same c...

Apply UUID function to database field from PHP

Hi all, I have this CodeIgniter and MySQL application. I have a database table where one field must be unique. When I "delete" a record from the table I don't want to really remove it from the table, I just want to set free the value of the unique field so it can be used for a future new record without conflicts and leave it there. At...

PHP MySQL - SQL Query Help

Hello, I have the following code to add users to a particular role. The code works fine but I'd like to change the SQL so it only inserts the user into a role if it doesn't already exist. Any help is greatly appreciated. Here is my code: // ------------------------------------------------------------------ // ADD SELECTED USERS...

Get records according to month names irrespective of value existence

Hi, I have to filter data for last 3 months from current date, so that would be to fetch data from Aug to Oct. But value exist for October only in mysql table, so now i want to display record in following format: Month Values Aug 0 Sept 0 Oct 10 But my query only shows October month records as i dont have...