sql

MySQL auto-store datetime for each row

Lately I've been doing quite a few projects that require the use of back-end, including MySQL. However I'm quite sick of adding the columns dt_created and dt_modified (which are date time stamps for creation and last modified respectively) to all the tables I have in my database. Everytime I INSERT or UPDATE the database, I will have t...

How can I rewrite this statement?

I have declared a variable @date SELECT @date = CASE WHEN MAX(dt) IS NULL THEN '31/12/2009' ELSE MAX(dt) + 1 END FROM mytab A code snippet where I am using the local variable CASE WHEN MAX(DateValue)= @date THEN NULL ELSE CONVERT(varchar(10), CONVERT(datetime, MAX(DateValue)), 103) END AS newdt I don't wa...

Seeing the underlying SQL in the Spring JdbcTemplate?

I am learning about the wonders of JdbcTemplate and NamedParameterJdbcTemplate. I like what I see, but is there any easy way to see the underlying SQL that it ends up executing? I'd like to see this for debug purposes (in order to for example debug the resulting SQL in an outside tool). ...

What Collation is the best for data type INT in MySQL?

When a filed is INT(data type), what should I choose as collation in MySQL? ...

SQL <-> Class (De)Serializer?

Today I learned this JavaScriptSerializer ser = new JavaScriptSerializer(); Foo foo = ser.Deserialize<Foo>(jsonSz); I had to match the class with the json I was pulling from a remote site. It saved me much time that I could just write the class and not worry about processing the data and putting them into the class. I also didn't need...

Which third party search engine (free) should I use ?

As the title says, I need a search engine... for mysql searching. My website is PHP based. I was going with sphinx but my hosting company doesn't support full-text indexes! So a search engine to be used without full-text! It should be pretty powerful, and must include atleast these functions below: When searching for 'bmw 520' only ...

what does Sql Server Management want to save into "Solution1"?

what is "solution1"? what is it for? When I exit ssms, it asks me to save something under Solution1 David ...

zend search engine, need some guidance in the right direction please

I have been looking at manuals of the Zend search engine, but I don't really understand much of it. I have a php website (classifieds) and I want users to be able to search my mysql database for records. Can someone explain a little more about the Zend search engine, and how I should actually 'install' it. I don't have my own server (h...

SQL Trigger Recursive update

Hello I have an organizational database where in it each employee have a foreign key to it's boss(FID). Table declaration: Create Table Emp( ID integer, FID integer, SALARY integer, Primary key (ID), foreign key (FID) references EMP ); The following sql trigger should update the employees under a boss. And then ...

Measuring performance for Single or multiple queries when you have large number of bridge tables

i asked this question around a single join or multiple (select n + 1) queries i wanted to find out if this was the same if you had many to many relationship and a lot of bridge tables for example, here are my tables: Table: People (id, first, last, age, phone, etc . .) Table: Roles (id, name) Table: PeopleRoles (id, personID, roleID)...

NHibernate and indexed views (materialized views)

Hi! Recently I was busy implementing paging functionality with NHibernate and things went smoothly with simple entities, but I hit a performance problem with those ones where multiple joins are required to acquire the requested page. Besides that, implementation would be much simpler if the queries could be performed by convention witho...

What should I do, create a search engine myself or use another one?

I have this classifieds website and I have now been searching for ways to implement a search function of the classifieds. I wonder, is there any tutorial for creating a pretty powerful search engine in PHP that you know of? I have looked into third party search engines, and it feels they are too much... PS: No full-text support on my ...

Ok, last question regarding search engine on my website...

I have read the intro to the zend manual, and as far as I understand I have to install the framework on my server... And my webhosting provider says they don't support that, so it's not possible... It must be installed in order for me to use it and implement a search function of my mysql records, right? Thanks ...

Finding non distinct rows

Assuming the following structure, I need to find if there are cases where there's more than one DESC for each CP4+CP3 combination. I need only to know if they exist. Not where they are. CP4, integer CP3, integer DESC, varchar(50) ...

how to combine 2 or more bridge tables in a single query

i have the following tables: Table: People (id, first, last, age, phone, etc . .) Table: Roles (id, name) Table: Skills (id, name) Table: People_Roles (id, personID^, roleID^) Table: People_Skills (id, personID^, skillID^) ^ = foreign key I basically want a query that gives me the full result set of all people and their roles and the...

what is the best db strategy for column indexing?

Two examples are: Columns that will show up in a queries where clause (where Name = "xtz") Columns that you are going to order (sort) on in queries Is this correct and are there other important use cases? Can SQL Server recommend fields to index based on usage patterns ? ...

MySQL and UTF-8

In MySQL, what is the difference between doing: SET NAMES 'utf8' And: SET CHARACTER SET 'utf8' I've taken a look at Connection Character Sets and Collations MySQL documentation page but I'm still a bit confused... Do both commands need to be issued in order to make MySQL UTF-8 aware? Or is SET NAMES enough? ...

Can I constraint an AutoIncremented column not to accept values from outside?

I have an AutoIncremented column (ID), and I want to have a constraint that only the database ever fills in this column. Is there a constraint for that? ...

Disallow inserting text values into integer columns

I accidentally tried to insert 'asdf' into an integer column. It worked (put 0 in the column), and gave this warning: Incorrect integer value: 'asdf' for column 'Author' at row 1 How can I cause similar insertions to fail instead of merely issuing a warning? ...

Rearrange column order in Sqlyog

Is it possible to rearrange a table's column order in SQL yog? ...