0
votes
1answer
29 views

if no file upload, file id in database should be: placeholder.gif

i have a form where you can put an image uploade, which is optional. with this script at the moment it writes upload/timestamp into my database. but i need to replace that with a placeholder if no ...
3
votes
1answer
20 views

Getting Error While Inserting Data into Table

I created a table user_info in postgresql with two columns of entryno and password. I used a single line of query : INSERT INTO user_info (entryno, password) VALUES ('2009cs10179','a'); But I got ...
0
votes
0answers
19 views

Get last recursive in mysql query

Let's say I have a table with 2 column. id and id_father. 1 null 2 1 3 2 How can I know, with a query ( in pgsql ) the id of the father ? I mean, If I look for the id 3. I will know that the ...
1
vote
1answer
36 views

SQL query to find counts of joined table rows as summary for each row

I have a table of widgets that looks like: id (integer) referrer (varchar(255)) width (integer) height (integer) ... and some others. I also have a table of events that look like: id (integer) ...
0
votes
2answers
38 views

Order of composite where clause (MySQL, Postgres)

I have a table t with columns a int, b int, c int; composite index i (b, c). I fetch some data with following query: select * from t where c = 1 and b = 2; So the question is: will MySQL and ...
1
vote
3answers
53 views

Reverse index for multiple keywords search

I am looking for an architectural solution to the following problem: General description of problem I have lots of distinct data entities (approximately 15 millions). Every entity is associated with ...
0
votes
2answers
33 views

Creating primary key on existing table sql

I have a table of the following form: create table tab1(i1 int, i2 character varying); I want to make i1 as the primary key. However my problem is i1 column contains duplicate rows. In order to ...
0
votes
2answers
46 views

Multiple applications accessing the same data

So my team is developing an API in PHP . My main concern is what happen 2 people call to update the same row. So if one API call will do a read then process info then write, what happens if another ...
1
vote
5answers
86 views

Thoughts on using email addresses as primary key

What are practices about using email addresses as the primary key? Should I avoid it and use an auto incremented ID number instead or is the engine able to handle it just as well? MySQL database but ...
0
votes
2answers
35 views

postgresql rails price range filter with between

I have the following array of price ranges how can I perform a query to find the price range between these using and operator This is the array I have ["0-1000", "5001_15000", "15001_25000"] ...
0
votes
1answer
12 views

Easily viewing postgresql and mysql results that are too wide for the terminal

I regularly use postgresql and mysql in the mac terminal, and I find that results that have a large number of columns become very difficult to interpret because the entire table becomes a mess. I have ...
0
votes
1answer
31 views

SymmetricDS: real time synchronisation of MySQL with PostgreSQL

I need to move a huge system from MySQL to PostgreSQL. This cannot be done in one go, which is why I need a robust (real time or near real time) data bi-directional synchronisation solution between ...
1
vote
0answers
14 views

How to write an event trigger which send alerts to a JMS Queue

Is there any example where, we can trigger an event to send messages to JMS Queue when a table is updated/inserted ect for MYSQL/Postgre?
0
votes
1answer
33 views

get all unique records and their corresponding column

Is it possible to get all unique records as well as their corresponding column in a database? something like: SELECT DISTINCT * FROM table_name ?where? I want to get all unique records with their ...
-2
votes
2answers
31 views

How to import PostgreSQL into MySQL database?

I have dumped a PostgreSQL database and I would need it to a MySQL as we migrate our project from Heroku to Amazon EC2, where is MySQL. It's quite a long time when I was doing something similar like ...
0
votes
0answers
16 views

How to fetch Heroku database and import it into a project on Amazon EC2?

On Heroku is PostgreSQL database, on EC2 MySQL. I downloaded database from Heroku through the addon called pgbackups, but when I open the downloaded file, the output is like 5047 444d 5001 0c00 0408 ...
-2
votes
1answer
27 views

Postgis functionalities in Microsoft SQL Server

I'm using Postgresql 8.4, Postgis 1.5 for My GIS works. Planning to change my Database to Microsoft SQL Server 2012. Can we use all the Postgis functionalities in Microsoft SQL Server 2012. Please ...
1
vote
3answers
68 views

aggregation and statistical 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 ...
0
votes
1answer
56 views

Add a subquery to SELECT statement that depends on the first column?

Is there a way I can write this query in a way to get the result of my sub query compared with my category_id. SELECT category_id, count(id) as TOTAL COUNT, (select count(*) from products where ...
0
votes
2answers
38 views

Rails mistakenly saying to add postgres to bundle

I have a rails project that uses mysql (and has so successfully in the past). However, after upgrading my postgres installation, this rails project is throwing the adapter not installed error: ...
1
vote
1answer
39 views

How do I preserve logical groupings while sorting in SQL?

I have two tables which are related in a parent-child relationship Sale sale_id | customer_name SaleItem item_id | sale_id | item_type Each Sale record has one or more corresponding SaleItem ...
1
vote
2answers
41 views

Activerecord ORDER BY FIELD

I am trying to do a "ORDER BY FIELD" in active record. I know that i can do it with MySQL but i am trying to keep my app agnostic and follow best practice. my production db is PostgreSQL the MySQL ...
0
votes
2answers
47 views

Read Lock in Ruby on Rails

There doesn't seem to be a built-in way to acquire a read lock in Rails (for a table). I know these are not typically ideal, but my use case seems to require one: There are a limited number of ...
0
votes
2answers
40 views

MySQL query fails in PostgreSQL

Using this query: users = User.where('confirmed_at is NULL AND confirmation_sent_at <= DATE_SUB(NOW(), INTERVAL ? days)', 1) In mysql goes okay but in Postgresql it fails with: ...
1
vote
3answers
50 views

Oracle to PostgreSQL query converter Possible?

I am thinking to write a converter that takes any oracle query and return Postgresql format of the query assuming table and columns are same. what I do right now I do timely conversions so I have ...
-3
votes
2answers
34 views

How the maximum value of Bytes is calculated?

Can any one tell me how the range of the data types are calculated? For example, in MySQL or PostgreSQL where we have smallint, integer and bigint, the range of smallint is from -32768 or +32767. How ...
1
vote
3answers
74 views

Postgresql select people you may know orderded by number of mutual friends

I'm building a social network, and I want my members to be able to easily find new friends. Just like in Facebook, I want to suggest them some people they may know by the number of mutual friends they ...
0
votes
2answers
29 views

Rank base on a column in one table

I have a simple table User with two attribute ID and AGE Now I want to get a 'rank' result base on AGE User Table ID AGE 0 23 1 35 2 30 3 52 4 35 5 23 ...
0
votes
1answer
41 views

MySQL/PostgreSQL record search: any alternative to LIKE?

I'm implementing a search system in my system and i'm curious about the usage of LIKE. Many websites and books "crucify" the usage of LIKE. But, what's the proper alternative? I really don't want to ...
1
vote
1answer
45 views

How do I selectively disable a remote db connection during rspec tests?

I have a configuration where, in addition to the local postgresql database, my Rails app also accesses a remote AWS database. My problem is that, even in tests that don't involve the remote database, ...
0
votes
2answers
47 views

Sql query to find subset of a given table

Given this table: http://www.w3schools.com/sql/trysql.asp?filename=trysql_func_sum How will I generate list of OrderIds where sum of quantity is at most 90. How do I express the same in SQL ? There ...
1
vote
2answers
43 views

Which database engine is most suitable to handle array values? [closed]

The often seen use case is when one store a list of tag to an item tag: [123,233,...], and the result should be query-able like "getting all rows with tag 233". Seems like the most advocated approach ...
0
votes
1answer
34 views

Using libpqxx for to store data in bulk OR how to use COPY statement in libpqxx

To insert bulk data/populate a database in PostgreSQL, the fastest way would be to use COPY. Source I have to populate a database. Right now I am getting write speeds as low as 100-200 per second. ...
0
votes
1answer
55 views

MySQL to PostgreSQL conversion and data synchronisation

I have a relatively large MySQL database (over 300 tables) which I desperately need to convert to PostgreSQL and synchronise data between the two databases if not real time then something close to it. ...
-3
votes
1answer
35 views

Please explain ST_GeomFromText parameters

I am having trouble understanding ST_GeomFromText. It looks like there are 3 sets of 2 numbers. Why is that? Wouldn't coordinates just consist of a latitude and longitude? Here is an example from ...
0
votes
0answers
87 views

Porting a MySQL password query to Postgres

I have a portion of a MySQL query which is designed to save a password using SHA512-CRYPT: SELECT ENCRYPT('firstpassword', CONCAT('$6$', SUBSTRING(SHA(RAND()), -16))) I need to port the application ...
0
votes
1answer
52 views

how to generate subsets from a query in postgres?

I need subsets of tuples for a given query. For example , if I need to find list of all employees who are older than 25 and limit that to atmost 5. how do I generate various subsets for the same ? ...
1
vote
1answer
46 views

SQL - find the closest pair of numbers to a provided pair

I have a DB Table where I would like to select the entry which is the closest match to a pair of provided values, whether positive or negative. Provided values: num1 = 2.5, num2 = 10.2 Compared ...
0
votes
1answer
41 views

Clojure QL : running plain SQL queries

are there any ways to perform the following queries in clojureql ? : insert into table1(id, name, age) select id, name, age from table2 create table t1 (id int, name varchar(50), age varchar(100)); ...
1
vote
2answers
46 views

What best way to include dll for tdbc::mysql&tdbc::postgres under windows starpack?

Packages tdbc::mysql and tdbc::postgresql require dll libmysql.dll and libpq.dll somewere in PATH. What best way to include this dlls into single starpack? For now I'm using following pkgIndex.tcl: ...
0
votes
1answer
54 views

Postgresql function If condition then run query else stop

I need some help with the following postgres functionality I have the following table with the columns: array, array_length I initially have a few arrays in and then I run a query(actually a set ...
0
votes
1answer
59 views

SQL query for calculating percentage completion of a survey

Here I have a survey and survey has many questions.Question has many answers.This is very basic relation of my survey.Every question is having a 'sequence number'.This 'sequence number' is used for ...
0
votes
1answer
30 views

Duplicating PostgreSQL database on one server to MySQL database on another server

I have a PostgreSQL database with 4-5 tables (some of those have more than 20 million rows). i have to replicate this entire database onto another machine. However, there I have MySQL (and for some ...
0
votes
1answer
55 views

Adodb using php with PostgreSQL

I have database name "TestDB" and under that I have table called "User". Above TestDB database and User table have been created in both mysql and postgres. I have written the following code. it is ...
3
votes
3answers
50 views

SQL query dynamic table name in FOR

I have a table tbl1 which has a column tbl_names. This column contains the name of some other tables. Now I want to write a query in the following format: select * from (select tbl_names from tbl1) ...
1
vote
1answer
53 views

How to Write subquery in sql to map dictionary values

I have a dictionary, which maps integers to string and another table which stores the relationship between integers: Dictionary (id, stringvalue) 1 Where 2 are you 3 ...
1
vote
1answer
37 views

Postegresql pattern matching utf8

In my mysql database I have a city name in utf-8: "Bucureşti" And if I do SELECT * FROM cities WHERE name LIKE 'Bucuresti'; <- without diacritic 'ş' it works in MySQL. How can I achieve ...
3
votes
2answers
52 views

How to Increment values without giving parameters

How can i increment the value of meeting and sub-meeting ids whenever a new meeting is created Table: "Employee" CREATE TABLE employee ( sno SERIAL, emp_id INTEGER, emp_name TEXT, ...
1
vote
3answers
41 views

Join dynamically on tables in Postgres

SELECT id, audited_rowk, name FROM audit_log_change AS C JOIN audit_log_action AS A ON A.id = C.action_id JOIN audit_log_table AS T ...
1
vote
0answers
53 views

postgres - modifying xml (MySql UpdateXml alternative)

I'm migrating mysql database to postgres and ran into a roadblock regarding some basic xml functionality. In MySql I had stored procedures which would replace nodes inside xml document but cannot ...

15 30 50 per page