这是表1:
col_1 col_2 date_1
----- ----- ------
1 3 2016
2 4 2015
Run Code Online (Sandbox Code Playgroud)
这是表2:
col_3 col_4 date_2
----- ----- ------
5 8 2014
6 9 2012
Run Code Online (Sandbox Code Playgroud)
我想要一个这样的结果:
col_1 col_2 col_3 col_4 date_1 date_2
----- ----- ----- ----- ------ ------
1 3 NULL NULL 2016 NULL
2 4 NULL NULL 2015 NULL
NULL NULL 5 8 NULL 2014
NULL NULL 6 9 NULL 2012
Run Code Online (Sandbox Code Playgroud)
有解决方案吗
我的表结构是:
CREATE TABLE IF NOT EXISTS `users_settings_temp` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`userid` int(10) unsigned DEFAULT NULL,
`type` enum('type1','type2')
`data` text,
`date_created` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Run Code Online (Sandbox Code Playgroud)
我想要做的是:
假设我想插入一个新条目,但我不希望它重复,谷歌周围,我发现这种格式:
INSERT INTO users_settings_temp(...)
ON DUPLICATE KEY UPDATE data = '{$data}'
Run Code Online (Sandbox Code Playgroud)
我猜问题出现在我的表中,主键=> id.如何更改表格,以便我可以使用:
INSERT INTO ... ON DUPLICATE KEY UPDATE
Run Code Online (Sandbox Code Playgroud)
我可以使用user_id + type作为主键吗?如果是的话,请你告诉我该怎么做?
我创建了一个表,但是我想创建两个表,当我点击"show"按钮时,我希望能够从两个表中选择内容并显示它们......这是我的代码...我在创建时遇到问题两个表并显示它们:
public class Entername extends Activity {
private Button showButton;
private Button insertButton;
private TextView nameEditText;
private TextView addTextView;
private Button doneButton;
public DatabaseHelper dbHelper = new DatabaseHelper(Entername.this,"pubgolfdatabase",2);
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.entername);
addTextView = (TextView)findViewById(R.id.textView1);
doneButton= (Button)findViewById(R.id.doneButton);
insertButton = (Button)findViewById(R.id.addButton);
nameEditText = (EditText)findViewById(R.id.name);
showButton =(Button)findViewById(R.id.button1);
showButton.setOnClickListener(new showButtonListener());
insertButton.setOnClickListener(new InsertButtonListener());
doneButton.setOnClickListener(new DoneButtonListener());
/** create the database if it dosen't exist **/
SQLiteDatabase db = dbHelper.getWritableDatabase();
try
{
db.execSQL("create …Run Code Online (Sandbox Code Playgroud) 也许你可以帮助我:
如果有一个table1:accounts
user_id account_id
39 3799207
39 80286966
40 3789458
Run Code Online (Sandbox Code Playgroud)
...
表2:订阅者
id client_id master_id master_account_id active
1 43 39 3799207 1
2 43 39 80286966 1
3 44 39 80286966 1
4 45 39 80286966 1
Run Code Online (Sandbox Code Playgroud)
...
使用此请求:
'SELECT account_id FROM accounts WHERE user_id = "39"';
Run Code Online (Sandbox Code Playgroud)
我可以得到这张桌子:
Account
3799207
80286966
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到这张表:
Account Subscribers Count
3799207 43 1
80286966 43,44,45... 3
Run Code Online (Sandbox Code Playgroud)
谢谢!
我正在使用Oracle11g来创建数据库应用程序.我的问题是我的数据库中有近100个不同的表,我想列出在特定日期之后创建的所有表.有没有办法列出这些表格.有人可以说如何完成这个简单的事情.谢谢.
我有一个像这样的 MySQL 表:

我想像这样将它从长格式转换为宽格式

对不起。我是新手,不知道如何张贴表格
是否有既定的方法/工具来根据Oracle DB表的列自动创建包含变量的生成C#class/struct?
我目前正在使用ODP.Net来处理Oracle DB中的许多表.为了方便我处理数据库表,我为每个我创建的表创建了一个独特的C#类,它存储了给定DB行的信息
目前,我手动制作每个班级.但我意识到随着桌子数量的增加,我的方式变得更加乏味.
任何人遇到同样的问题,有一个很好的工具来缓解任务?
with TdmBCElections.Create(Self) do
begin
with dmBCElections, qryParties do
begin
SQL.Clear;
if rgpParty.ItemIndex = 0 then
SQL.Text := 'SELECT StrConv(P_Surname, 3), StrConv(P_Names, 3) ' +
'FROM Parties WHERE P_Type = "HEAD"'
else
SQL.Text := 'SELECT StrConv(P_Surname, 3), StrConv(P_Names, 3) ' +
'FROM Parties WHERE P_Type = "TEACHER"';
Open;
while not Eof do
begin
cmbDetails.Items.Add(qryParties['StrConv(P_Surname, 3)'] + ', ' +
qryParties['StrConv(P_Names, 3)']);
Next;
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)
上面的代码给出了以下错误消息:
当StrConv应用于它们时,如何调用表字段?