sql

mysql wildcard (ignore one/two characters in search)

I'm trying to update tables in my wordpress mu database. I want to update all wp_options tables. These tables are named like this: wp_1_options wp_2_options ...and so on. How do i affect all tables with wp_any-character-here_options? I tried to query for: UPDATE wp_%_options SET option_value = replace(option_value, 'http://www.o...

Selecting the items associated with a tag along with the tags associated with these items

2 tables: items(item_id, ...) tags(tag_id, item_id) How do I select the items (from the "items" table) that have a particular tag associated with them (in the "tags" table) along with all the tags associated with these items? ...

please help me to create a sql query

i have following 3 tables CREATE TABLE [dbo].[dspartner]( [dspartnerid] [bigint] IDENTITY(1,1) NOT NULL, [name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [priority] [int] NULL) CREATE TABLE [dbo].[hotels]( [hotelid] [int] PRIMARY KEY IDENTITY(1,1) NOT NULL, [name] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS...

mysql: change http://old-domain.com to http://new-domain.com in all tables

I'm using statements from here: http://www.mydigitallife.info/2007/10/01/how-to-move-wordpress-blog-to-new-domain-or-location/ but i had to modify them because i'm using multi-user and it has different table structure (weird numbered tables). As you can see in my previous question it's all REALLY problematic... So my question is: Can ...

Is " SQL Helper Class " in Microsoft Application Blocks for .NET is excellent ?

Dears from years go i use "SQL Helper" class that exist in Microsoft Application Blocks for .NET and i used it for about 1 year in many projects but after that many senior recommend me not to use as it's have many problems in big projects and i let it but know in a new company they want to use it in a projects ... Could any make hi...

"access denied" error in phpmyadmin

We've decided to move one of our websites from one web hosting service to another. So, I backed up all the files and transfered them to the new host. Here's the problem I can't import the sql file into new database on the new host, I get "Access denied" error. weird. I'm using CPanel version 11. Any idea? ...

Sql server takes too long time for update query to execute for few rows

Hi Guys, UPDATE table1 SET col1='True' This query takes more than 30 secs for about 6000 records. Why is it so slow? ...

How to implement tag counting

I have my tags desinged like this in my database: Table: Item Columns: ItemID, Title, Content Table: Tag Columns: TagID, Title Table: ItemTag Columns: ItemID, TagID //example -- this is the right sidebar of stackoverflow c# × 59279 sql × 14885 asp.net-mvc × 9123 linq × 4337 tags × 339 if I wanted to know the count of each ta...

SQL to Linq equivalent

I've got this stored procedure I'd like to convert to LINQ to SQL, but I'm having a bit of trouble because I'm new to LINQ (and actually, I'm no SQL guru) and I am not getting the expected results. (I tried calling the SPROC from LINQ to SQL but when I send in the Period datetime as parameter on the SPROC I get some error on L2S about th...

Check In between two times

I want to check in IF in sql server.. I am having check in time and parm1time and paramtime2 I want to return the value if checkin time is between param1 and param2 how can I write. Example @checkin = 10.00 param1 = 2.00 param2 = 13.00 How can I do this in sql query IF COndition ...

How do I save the values of checkboxes in a form into a single MySQL field?

I have a form where i have many music genres. An artist can be singing under many genres. I have put the genres in checkboxes. Now i need to store the values of the checkboxes in to a single field. Can some one help me out with some code snippet as i am new to php programming? ...

How to store arrays in a database?

I have a simple messaging system that up till now uses file based storage. Because the number of users of the system is increasing gradually I would like to switch over to database based storage. In code the message server maintains a list of users (with their credentials) and a list of messages. A Message object has as its main fields a...

inner join on null value

I'm not sure if i made a mistake in logic. If i have a query and i do an inner join with a null value would i always get no results or will it ignore the join and succeed? example user { id PK, name NVARCHAR NOT NULL, banStatus nullable reference } if i write and u.banStatus i will receive no rows? select * from user as u join banst...

SQL result to PHP multidimensional array

Hi, I'm retrieving some hierarchical data from an Oracle database using the "connect by" function. Then I populate a PHP array with the result of my query looking like: while ($row_branches = oci_fetch_array($query_tree)) { $tree[] = array( 'id' => $row_branches['ID'] , 'parent' => $row_branche['PARENT'] , 'data' => htm...

Cross-tab Query

Hello, I have a table with employee attendance - lets say - OATT. Following is the structure and sample data AttDate EmpId EmpName AttCode InTime OutTime 01-10-2009 1 Jain, Rahul P 0900 1830 02-10-2009 1 Jain, Rahul P 0900 1830 03-10-2009 1 Jain, Rahul P 0900 1830 04-10-2009 1 Jain, Rahul P 0900 1830 05-10-2009 1 Jain, Rahul P 0900 18...

What GUID can I use as a placeholder

I have a database table that has a non null column of type uniqueidentifier. This was put in place for use in the near future. But for now, I need to use some placeholder. Can I simply use: 00000000-0000-0000-0000-000000000000 for all the rows until a real guid is used when new rows are inserted in the future? Does SQL Server enforce ...

mysql: find rows which have a field that is a substring of "string"

is there a way to write an sql query that finds all rows where the field value is a substring of a given string. Example: table names Name | Nickname rohit iamrohitbanga banga rohitnick sinan unur query should be something like select * from names where Name is a substring of "who is rohit...

Can this sql query be simplified?

Hi! I have a Sql Query: select * from contactmeta WHERE contactmeta.contact_id in ( select tob.object_id from tagobject tob, tag t, taggroup tg where tob.tag_id = t.tag_id and t.tag_group_id = tg.tag_group_id and tob.object_type_id = 14 and tg.org_id = contactmeta.group_id and (t.name like '%campaign%') ) AND contactmeta.contact_id...

creating multiple tables with single sql command

I searched for this here and on google and surprisingly couldn't find an answer. I tried to create syntax to submit to mysql that would create multiple tables with the same columns, but it returned an error. Can you point out what is wrong with my syntax, or if this is even possible? CREATE TABLE news, life ( id int PRIMARY KEY AUTO_...

MySQL querying products from one table only if they appear in certain category table

I've got the following tables: Products: id, name, ... Products_in_Categories id, category_id, product_id Categories id, name, ... I have an admin page where I want to let him search products by name, catalog id etc. And of course by category and name and catalog id ... So without the category - it's really easy. But when I w...