sql

MySQL full text search (php)

Hi I'm trying to create a search box to search customer by last name and/or first name and/or phone number. Here is my SQL Query: SELECT * FROM customer WHERE Match(c_fname,c_lname,c_phone) Against('$keywords') My questions is Why does it work when i search for bill and not if i search for bob? Another question is how do i prio...

need help with my database design

I really really cant get my head around this, i've thought about this for ages but the penny wont drop. I have just started learning php and sql so for all i know its probably really simple. I want to create a football application with leagues, fixtures, and results for a pc football game that a group of us in college play. The idea is t...

does quoting order by matter?

I am using mysql and the following two sqls produce different result. SELECT developers.* FROM "developers" ORDER BY id DESC LIMIT 1 SELECT developers.* FROM "developers" ORDER BY 'id DESC' LIMIT 1 I thought that quoting order by should not matter. ...

Ibatis: Define a getter as a property on a result

Hi, Can I define a getter as a property on a result in Ibatis? like <resultMap id=.... class=...> <result property="getSomeValue" column="valueColumn"/> .... I haven't seen this in documentation so far. ...

Oracle outer join short hand with upper

Works: AND UPPER(a.name) = b.lname(+) does not work AND UPPER(a.name) = UPPER(b.lname) (+) Moving to ANSI joins is an option but a painstaking one. This code should be changed in lot of places and there are lot of joins. I would like to get this syntax correct and be on my way. Is it possible? ...

what's the purpose/point of the REAL() Datatype in mysql?

what's the purpose/point of the REAL() Datatype in mysql? You have float,double and decimal which i understand but where does the "real" datatype come into it? Any ideas? Thank you in advance ;-) is real the same as float or double? ...

Why would this SQL error with "Invalid use of group function"?

This is a simple query ran when the user presses logout from my website UPDATE `user_logins` SET `active` = 0 WHERE `user_id` = 3 AND `datetime` = MAX(`datetime`) LIMIT 1 The user_id value is binded in there with PDO. I get the following exception thrown Invalid use of group function Googling around seems to say that ...

Select data, setting a calculated value into a column

Hello all, I'm selecting data from a table within a trigger (FOR UPDATE). Some rows I'm selecting have been updated by a transaction, that initiated the trigger, and some rows are not. I'd like to write somewhere in the dataset a flag for every row, which value would be calculated as "id IN (SELECT [id] FROM INSERTED)". This flag would ...

Update and function

I am a student, this is part of my homework. I have to Update two employee's pay by 10%...is there a function for that or do I have to calculate the figures and just change the numbers i.e. update Employee set Wage=10 where Wage=51000 This is the entire question: choose an EEO-1 Classification: Increase all employees’ salaries that ...

How to set up ASP.NET SQL Datasource to accept TVP

In the codebehind you would add the TVP as a SqlDbType.Structured for a stored procedure But this doesn't exist in an ASP.NET SqlDataSource control. I have stored my Datatables in session variables (don't worry they are small!) and I need to pass those as parameters to the SqlDataSource (which has a number of databound objects) I point...

MySQL "an error in your SQL syntax"

Hi! I'm trying to change a database entry with PHP but is stuck with this error message: Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Bjelkholm Lövgren AND adress = Brinellgatan 14 AND postnummer = 57135 ' at line 1 Code: ...

Will index be used when using OR clause in where

I wrote a stored procedure with optional parameters. CREATE PROCEDURE dbo.GetActiveEmployee @startTime DATETIME=NULL, @endTime DATETIME=NULL AS SET NOCOUNT ON SELECT columns FROM table WHERE (@startTime is NULL or table.StartTime >= @startTime) AND (@endTIme is NULL or table.EndTime <= @endTime) I'm won...

PHP / MySQL question, more the latter

So, I need some code help. I've got an awkward little MySQL table that just keeps growing and growing. Let's assume that a set of clients, some in certain countries, that I need to 'total' the invoices for (need to calculate GST) So, two tables contain the data I need -- one table has their ID and their country (In this case, Canada!)....

Alternate to Left Joins on large datasets

If I needed to do a left join between 2 tables (in order to run some kind of analysis between them), but both datasets are too large for this to be executed in a single query, what's the best practice to accomplish this? I saw FETCH in the documentation but wasn't sure if this is conventionally used to loop over entire datasets. Since I...

Constraining queries based on aggregations of properties of associations

Quick question: would this trigger one query per each Tag item? public static IQueryable<Tag> WhereTagHasLivePosts(this IQueryable<Tag> q) { return q.Where(t => t.Posts.Where(p => DateTime.Now >= p.PublishTime && p.IsPublished == true).Count() > 0); } t.Posts.Where is actually an extension on IEnumerable, rather than IQueryable, s...

Limit the field that are syncronized

Hi I'm building an application that runs on a Windows Mobile device. I'm using Microsoft's Sync Framework to sync the Sql CE database with the main corporate db. The question is how can I limit the fields that are syncronized? The table in question has stacks of fields but I only need to display a few of them on the mobile device and ...

Will this Post/Tag DB schema cause problems later?

I'm planning a new service for my ASP.NET MVC app and want to use tags. I've never really been too fond of tags, but SO delivers so I'll give it a shot. Here's the simplified schema I'm thinking about: Post Table ------------------ PK PostId BigInt (or perhaps uniqueidentifier) ...more post related fields... Tags nvarchar(200) Then I...

Help with sql query

Hello guys need help with a query. Consider the following table I need to select first the sum of each Code from table. I am doing it with simple sum and group by statement. Then I have to subtract the results from each code sum where type='r' 1)Say for first part of query, we will get 2 rows from SUM (one with total USD and one with...

complex sql query

There is a customer table. I want to list active and deactive status in one query. How can I do this ? SELECT count(*) as ACTIVE, count(*) as DEACTIVE FROM V_CUSTOMER WHERE STATUS='a' AND STATUS='d' ...

Show item of the day

Hi, I am looking to create a function that gets me a random item from a mySQL table, but let's me keep the returned as the "item of the day". In other words, the item that was "the item of the day" yesterday should not be shown again until all other items have been shown as item of the day. Any suggestions on how to do this in an eleg...