473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Select from 2 tables and reselect if not exists

Hello

I have 2 tables,


Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `events` (
  2.   `id` int(11) NOT NULL auto_increment,
  3.   `type` int(1) NOT NULL,
  4.   `typeid` int(5) NOT NULL,
  5.   `dt` datetime NOT NULL,
  6.   `locationid` int(11) NOT NULL,
  7.   `status` tinyint(1) NOT NULL,
  8.   PRIMARY KEY  (`id`)
  9. ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
  10.  
  11. CREATE TABLE `events_language` (
  12.   `id` int(5) NOT NULL auto_increment,
  13.   `eventid` int(5) NOT NULL,
  14.   `title` varchar(255) collate utf8_unicode_ci NOT NULL,
  15.   `text` text collate utf8_unicode_ci NOT NULL,
  16.   `languageid` int(2) NOT NULL,
  17.   PRIMARY KEY  (`id`)
  18. ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
  19.  
Now I select from this 2 tables and join them on events.id and events_language.eventid. I also include languageid as I'm making multilanguage site. Now the problem is that users will insert this data and I'll have around 5-6 languages and nobody will insert all fields. So my solution was to load all events and then if there is no input in events_language with specific languageid, then load some other language...

is this possible?
Jul 19 '08 #1
1 2027
r035198x
13,262 8TB
Try using a CASE.
Jul 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Michael | last post by:
I have two tables with a 1-many relationship. I want to write a select statement that looks in the table w/many records and compares it to the records in the primary table to see if there are any...
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
4
by: stoppal | last post by:
I need some help. I am trying to write a query which does the following SELECT * from table1 where field1=(SELECT distinct field1 FROM table1 WHERE field2='2005' or field2='2010')
6
by: Eric Robinson | last post by:
Hi all, I'm having real trouble wrapping my newbie brain around this problem. Can someone please tell me the most efficient (or any!) way to write a SELECT statement to return a set of rows from...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
13
by: andro | last post by:
Hi everybody! I have several tables from which I want to exract the SAME value (along with other referenced data). All the values are in the same column within the tables. How can I achieve...
3
by: Mich | last post by:
Hi, the table 'l0382_project1' exists in sql server. I can see it. Now in asp.net, i want to check whether it exists but i get "invalid column name": 1st attempt: comd.CommandText = "SELECT...
1
by: rehanmomin | last post by:
BACKGROUND I was trying the figure out a query for my sisters optometrist office. I have two tables, one that contains customers demographics and another table that contains patient's examination. ...
1
by: Jonathan Woods | last post by:
Dear Gurus, How do I determine if data exists from multiple tables in SQL Server 2000? For example, IF EXISTS ( ( SELECT ColA FROM TableA WHERE ... ) AND
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.