mysql

changing left join to basic join

Hi there, I currently have some SQL that should return 3 rows of data but returns 6 (3 rows repeated twice). I believe this is down to my syntax and want to try and build the query using basic joins, currently the SQL looks like this, `function getMultiContentById($id) { $query = "SELECT FROM `mailers` LEFT JOIN `mailer_co...

Is it possible to show data of different encodings in the same page?

I have two tables here - one is in UTF and holds Arabic text as it can be read. The other one has a different encoding however and the content is Arabic however in the database its displayed as ÈöÓúãö Çááøåö ÇáÑøóÍúãóäö ÇáÑøóÍöíãö I have to show data from both tables on the same page - the page is UTF encoded however I'm not sure if ...

Checkbox selection of database tables to include in Ruby on Rails view

I am working on a Ruby on Rails project where people can keep a diary for diseases or health conditions of their interest. They can (de)select multiple topics in their preferences with the help of checkboxes, and get disease specific questions and tracking options for their 'diseases of interest' on their personalized site. I am not very...

MySQL LIKE wildcard for table

Hi, I have a PHP document which will execute some MySQL and echo it back. Code: $query1 = "SELECT * FROM feed, recipients WHERE feed.title LIKE \"%recipients.suburb%"\ ORDER BY pubDate DESC"; recipients.suburb (table.column) is in my MySQL DB. How can I perform wildcards on this? This works, but I cant do it to tables? $query1 = "SE...

Make a query in mysql without invoking a trigger (How to disable a trigger)

I have 2 tables: comments and comments_likes. comments id message likes triggers: AFTER DELETE DELETE FROM comments_likes WHERE comment_id = OLD.id; comments_likes id comment_id triggers: AFTER INSERT UPDATE comments SET likes = likes + 1 WHERE comments.id = NEW.comment_id; AFTER DELETE UPDATE comments ...

SSH Tunnel for Python MySQLdb connection

I tried creating a SSH tunnel using ssh -L 3306:localhost:22 <hostip> Then running my python script to connect via localhost conn = MySQLdb.connect(host'localhost', port=3306, user='bob', passwd='na', db='test') However, I receive the following error (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql....

MySQL Error: Can't create/write to file Errcode: 17

Hi, We are working on a data migration project in which the source and target databases are MySql (Version : 5.0.45-community-nt). Currently both the source and target databases are hosted on my local machine (Windows XP SP2). We are using a tool called “Pentaho spoon” for writing the ETL scripts for migration. The spoon transformatio...

Parameters not passing from HTML form to MySQL (via Tomcat, Eclipse(IDE), Servlet, and Java Bean)

I am designing a small web application for learning purpose using Apache Tomcat, Eclipse, Java EE (Servlet, JSP, Bean), MySql Database as backend. I have configured Eclipse to include Tomcat, MySql connector. The Project: A HTML form for entering UserName, Email, and Password. Servlet for passing parameter to Java Bean. Java Bean t...

Mysql query help with where clause

Community Service Table |student name (id in real table)|hours|year|event name (id in real table)| |Johnny Smith | 5|2010|Beach Clean-up | |Samantha Bee | 3|2011|Daily Show Volunteering | |Samantha Bee | 2|2011|Daily Show Bake Sale | |Bilbo Baggins...

Generating a CSS file from file or database (PHP)

I want to generate a CSS file based on the users choices. I am considering which way would be best. On example is to use arrays and save them in a XML file or use a key/value store like Mongo DB. In that way the array can be pulled from the XML or key/value database, modified and saved. After that a CSS file would be generated based on...

Appending one sql query with another.

Hi, I have a datareader that binds a sql select (with 10 columns from table1) , i want to append another with 5 different cols from table2 to this first sql select, i can't do UNION as it has different number of columns, (one query has 10, another returns 5 cols). Is there any other way of implementing this, via mysql? Also i need to ...

MySQL error: 2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0"

I'm having an issue connecting to my local MySQL database using Python's MySQLdb library. The script has been working well previously, but I will occasionally get the MySQL error in the title. There seems to be no explanation for when the error occurs, and the script is always run from the same machine with the same arguments. The MySQ...

MySql: Ordering results by number of matches in a space-delimited value column

I have a MySQL database table that has a "word" column with space-delimited values. For example: one two three four five So given the record above, I want to find other records that contain one or more of those space-delimited values, and order the results by most number of relevant matches. How can I go about achieving this? For e...

How to generate a unique text id for a online resource

Hi, I want to generate a unique id which will be used in URLs to identify a specific resource. In principle it is the same as pastebin.com etc. does. The id and resource is not very secret but I want it to be so you just can't decrement a id and then get another users resource. I´m thinking of a CHAR(8) which will look nice in a URL an...

getting data from 3 tables via a recurring id

I have a database with 3 tables in this structure, CREATE TABLE `mailers` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mailer_title` varchar(150) NOT NULL, `mailer_header` varchar(60) NOT NULL, `mailer_type` enum('single','multi') NOT NULL, `introduction` varchar(80) NOT NULL, `status` enum('live','dead','draft') NOT NULL, ...

Edit text in columns

Just wondering if someone can assist me with the following issue. I have a database in MySQL and I'm using PHPMyAdmin to interact with the database. So within the table example_table_name I have two columns product_item_short and product_item_long which have URL's in them. Now there is 3000 rows of data and as an example the URL in eac...

Getting all articles with a GROUP_CONCAT field of their tags

Hi everyone, I have a table articles, another tags, and a third called article_tags. I want to produce a page which lists all of the articles for a specific tag. My query looks like this: SELECT headline, GROUP_CONCAT(tags.tag_name) AS all_tags FROM articles LEFT JOIN articles_tags ON articles.article_id = articles_tags.article_id LEF...

how to query related three related tables using one query

I have three following tables. The relationship is that each report_param and report_frequency is tied together using the intermediate table report_freq_map. Is it possible to construct an SQL so that user can select all the report_param rows using the constraint like frequency='daily', instead of using frequency='1'. Thanks, -peter...

Purpose of MySQL data type

Often when creating a new web app and configuring MySQL, certain fields will need to change in format as the app develops. For instance, I may change the format of a date field or a field which once was just int now needs a letter or what not. So usually I just make every field Varchar 255 until Im finished at which time Ill change dat...

Entity Model Zero To One Should be One to Many?

Here is part of my Entity Model which I just generated from a MySql database. My question is why are the tables UserNotes and UserLoginHistory coming out as Zero to One. When I change them to many (collection of usernotes) I get the error: Error 1 Error 113: Multiplicity is not valid in Role 'user_notes' in relationship 'UserIdFKeyNo...