MYSQL - Whitespace issue Group by

I am performing UNION while getting the same type of information (company_name, vat, and email) from two different tables (adv and pub). The SQL query is below: SELECT TRIM(UPPER(company_name)), vat, company_owner_email FROM ( (SELECT company_name, v

O WH and O WH or O WH Laravel Query?

I am trying to do a "WHERE AND WHERE OR WHERE" query with laravel, basically what I want to do is get all the events where the user_id equals a certain something AND where type = 'something1' OR 'something2' but right now the event is now only s

Calculate the average of two tables

I am new to SQL and I just can't figure out how to calculate the average of a certain value in two tables. I have one table that is having all the information of the lakes in the world and i have another tables including all the information of the se

Convert 31/07/2010 to Date format as 2014-07-31

Is there a function wich can convert a date in format like : 31/07/2014 to a format date like 2014-07-31 I want to do this because in my sql query when i put the date in the format with " / " it doesn't understand te format :/ I have this messag

How to join two tables with a different pass number? mysql

I want to run this query : SELECT firstName , secondName , lastName FROM (SELECT firstName,secondName,lastName FROM table1 UNION SELECT firstName,NULL,NULL FROM table2 )resutls I want add two Null columns to the second test, How could I do that ? or

How to select the column name in the select statement

I want to copy/update data from Table A to Table B. Table B has some more additional columns. I have tried the following options. 1) `REPLACE INTO `B` (SHOW FIELDS FROM 'A') SELECT * FROM `A 2) `REPLACE INTO `B` (SELECT `COLUMN_NAME` FROM `INFORMATIO

Connect the mysql database using odbc in vbnet

I have a mysql database on phpmyadmin, I installed the connector 6.8.3 (http://dev.mysql.com/downloads/connector/net/) I add a reference on the driver ((c:\Program Files\MySQL\MySQL Connector Net 6.8.3\Assemblies\v4.5\MySql.Data.dll) and I use this c

MySQL reads, calculates and rewrites

I need help with some MySQL commands. My MySQL table look's like this mysql> DESCRIBE sensor_readout; +-----------+-----------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-----------+------

aggregation and statistics functions on NOSQL databases

Using SQL databases, it is easy to do statistical / aggregate functions like covariance, standard deviation, kurtosis, skewness, deviations, means and medians, summation and product etc, without taking the data out to an application server. http://ww

How to create a database on a google cloud sql instance

How can I use Cloud SQL to create a database? When I use MySQL, I could easily run a sql script to create them on phpMyAdmin. I found a site that advertises that it's possible to run SQL files right on Google Cloud SQL. This is exactly what I want to

insert multiple fields using the foreach loop

I have a problem when I want to insert multiple fields into one table. Here's my form: <h1>Add user</h1> <form method="post" action="index.php"> <table> <thead> <th>Name</th> <th>Age</

Storing calendar data in MySQL

Just a quick architecture question really on storing calendar data. Basically, I have a database of services for rental. On the front end, there is a calendar to show either "Available" or "Unavailable" for every future date. In the ba

Pagination of a mixed ActiveRecord request

I am attempting to paginate a shuffled ActiveRecord query. The syntax for doing this using the Kaminari gem is: @users = Kaminari.paginate_array(User.all.shuffle).page(params[:page]).per(20) The issue with this is that User.all is re-shuffled on each

UTF8 - & gt; Latin1 Difficulty, PHP

I'm losing accented characters. From PHP I download an xml file which uses UTF8, while my PHP script uses Latin1. I can't manage to convert the UTF8 into Latin1. I've tried this: $meta=mb_convert_encoding($meta,'CP1252','UTF-8'); and $meta=mb_convert

The best way for Unique Random String for MySQL long table

I know how to create random chars both at PHP and MySQL but the question is that I have to create a 4 char random string for a table of 10 thousand or so rows. What way is the best to make sure it will remain unique? I can use a longer string if I ne

Creating a multidimensional array from the database

I really hope someone can help me with this. I'm struggling with it for nearly two days now... I have a DB-table "Device" and a table "Connection". I'm using it to visualize my company's network. To pass the data to the JS-framework I

Join several (4) tables in MYSQL

I have four tables I want to join and get data from. The tables look something like... Employees (EmployeeID, GroupID[fk], EmployeeName, PhoneNum) Positions (PositionID, PositionName) EmployeePositions (EployeePositionID, EmployeeID[fk], PositionID[f